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 若愚若怯 阅读(479) | 
评论 (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 若愚若怯 阅读(1354) | 
评论 (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 若愚若怯 阅读(305) | 
评论 (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没有重写对于请求和响应的处理方法: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 若愚若怯 阅读(1091) | 
评论 (0) | 
编辑 收藏