posts - 6,  comments - 0,  trackbacks - 0
          1.項目的目錄結構圖:



          2.web.xml

           1 <?xml version="1.0" encoding="UTF-8"?>
           2 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
           3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
           5     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
           6     
           7     
           8     <!-- spring監聽器,監聽springMvc環境 -->
           9     <listener>
          10         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          11     </listener>
          12     <!-- 加載spring的配置文件 -->
          13     <context-param>
          14        <param-name>contextConfigLocation</param-name>
          15        <param-value>/WEB-INF/springmvc-servlet.xml</param-value>
          16     </context-param>
          17     <!-- 配置Spring MVC DispatcherServlet -->
          18     <servlet>
          19         <servlet-name>springmvc</servlet-name>
          20         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          21         <load-on-startup>2</load-on-startup>
          22     </servlet>
          23     <servlet-mapping>
          24         <servlet-name>springmvc</servlet-name>
          25         <url-pattern>*.do</url-pattern>
          26     </servlet-mapping>
          27 </web-app>



































          3


          posted @ 2014-03-15 10:36 若愚若怯 閱讀(470) | 評論 (0)編輯 收藏
          1.下圖說明Spring MVC中請求被處理的過程:


          posted @ 2014-03-13 21:02 若愚若怯 閱讀(167) | 評論 (0)編輯 收藏
          Oracle:
              || 或  concat()
          SQLServer:
             +
          MySQL:
            CONCAT()
          DB2:
            || 或  CONCAT()
          posted @ 2014-03-12 12:51 若愚若怯 閱讀(119) | 評論 (0)編輯 收藏
          示例:向學生表中添加記錄
          1.MySQL:
                  <insert id="addStudent" parameterType="Student" keyProperty="id">
          insert into student(id,name,birth,score)
          values(#{id},#{name},#{birth},#{score});
          <selectKey resultType="int" keyProperty="id">
          SELECT
          LAST_INSERT_ID() AS VALUE
          </selectKey>
          </insert>
          2.SQLServer:
                  <insert id="addStudent" parameterType="Student" keyProperty="id">
          insert into student(name,birth,score)
          values(#{#{name},#{birth},#{score});
          <selectKey resultType="int" keyProperty="id">
                          SELECT STOCKIDSEQUENCE.NEXTVAL AS VALUE FROM DUAL
          </selectKey>
          </insert>

          3.Oracle:
                  <insert id="addStudent" parameterType="Student" keyProperty="id">
          insert into student(name,birth,score)
          values(#{#{name},#{birth},#{score});
          <selectKey resultType="int" keyProperty="id">
          select @@identity as inserted
          </selectKey>
          </insert>
          posted @ 2014-03-10 10:55 若愚若怯 閱讀(1344) | 評論 (0)編輯 收藏
          代碼如下:
          String strDate = "2014-03-10";
          StringTokenizer st = new StringTokenizer(strDate, "-");
          Date date = null;
          date = new Date(Integer.parseInt(st.nextToken()));
          搞定!
          posted @ 2014-03-10 09:22 若愚若怯 閱讀(297) | 評論 (0)編輯 收藏
          Type:         Status Report
          Messsage:  HTTP method GET is not supported by this URL
          Description:    
          The specified HTTP method is not allowed for the requested resource.

          錯誤原因:
                        1.
          繼承自HttpServlet的Servlet沒有重寫對于請求和響應的處理方法:doGet或doPost等方法;默認調用父類的doGet或doPost等方法;
                        2.
          父類HttpServlet的doGet或doPost等方法覆蓋了你重寫的doGet或doPost等方法;
                       父類HttpServlet的doGet或doPost等方法的默認實現是返回狀態代碼為405的HTTP錯誤表示對于指定資源的請求方法不被允許。
          解決方法:
                       1.子類重寫doGet或doPost等方法;
                       2.
          在你擴展的Servlert中重寫doGet或doPost等方法來處理請求和響應時 不要調用父類HttpServlet的doGet或doPost等方法,即去掉super.doGet(request, response)和                            super.doPost(request, response)。
                          如果子類僅僅重寫的是doGet或doPost其中一個方法,而沒有另一個方法,也會報405錯誤
          posted @ 2014-02-10 13:32 若愚若怯 閱讀(1086) | 評論 (0)編輯 收藏
          僅列出標題  
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 江华| 新乡县| 哈巴河县| 闽侯县| 明水县| 清水县| 太湖县| 苏州市| 疏勒县| 靖安县| 姜堰市| 吉安市| 扬中市| 伊通| 水城县| 尚义县| 岳西县| 会泽县| 南平市| 荆州市| 余干县| 涟水县| 伊宁市| 丹江口市| 安福县| 大同市| 龙里县| 仙游县| 蓝田县| 浦江县| 喜德县| 永兴县| 隆林| 晋中市| 伊春市| 海口市| 贡山| 弋阳县| 北安市| 望江县| 象山县|