主題:spring mvc RESTful風格開發配置:
第一步:
<!-- spring mvc RESTful風格的web.xml配置 -->
<servlet>
<servlet-name>spingmvc_RESTful</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- spring mvc的配置文件路徑 -->
<param-value>classpath:conf/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spingmvc_RESTful</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>web
第二步:
<!-- spring mvc 配置文件對靜態資源的解析 -->
<!-- 配置註解驅動 -->
<mvc:annotation-driven />
<!-- 對靜態資源的解析 -->
<mvc:resources location="/jsp/" mapping="/jsp/**"></mvc:resources>
<mvc:resources location="/commons/" mapping="/commons/**"></mvc:resources>spring
第三步:
<!-- spring mvc Controller的編寫 -->
@RequestMapping("/toOrderUnsubList/{unsubId}")
public String toOrderUnsubList(HttpServletRequest request,
HttpServletResponse response,
Model model,
@PathVariable("id") String id) throws Exception{
System.out.println(id);
return "orderUnsub/orderUnsubList";
}spring-mvc