1.項目的目錄結(jié)構(gòu)圖:

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監(jiān)聽器,監(jiān)聽springMvc環(huán)境 --> 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 若愚若怯 閱讀(467) |
評論 (0) |
編輯 收藏
示例:向?qū)W生表中添加記錄
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 若愚若怯 閱讀(1341) |
評論 (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 若愚若怯 閱讀(294) |
評論 (0) |
編輯 收藏
Type:
Status ReportMesssage:
HTTP method GET is not supported by this URL
Description: The specified HTTP method is not allowed for the requested resource.
錯誤原因:
1.繼承自HttpServlet的Servlet沒有重寫對于請求和響應(yīng)的處理方法:doGet或doPost等方法;默認調(diào)用父類的doGet或doPost等方法;
2.父類HttpServlet的doGet或doPost等方法覆蓋了你重寫的doGet或doPost等方法;
父類HttpServlet的doGet或doPost等方法的默認實現(xiàn)是返回狀態(tài)代碼為405的HTTP錯誤表示對于指定資源的請求方法不被允許。
解決方法:
1.子類重寫doGet或doPost等方法;
2.在你擴展的Servlert中重寫doGet或doPost等方法來處理請求和響應(yīng)時 不要調(diào)用父類HttpServlet的doGet或doPost等方法,即去掉super.doGet(request, response)和 super.doPost(request, response)。
如果子類僅僅重寫的是doGet或doPost其中一個方法,而沒有另一個方法,也會報405錯誤
posted @
2014-02-10 13:32 若愚若怯 閱讀(1081) |
評論 (0) |
編輯 收藏