标签:map exception 传递 实现 numbers tran cep 根据 解释
RESTful即Representational State Transfer的缩写。
综合上面的解释,我们总结一下什么是RESTful架构:
http://localhost:8080/items/editItems.action?id=1&....
http:// localhost:8080/items/editItems/1
<servlet>
<servlet-name>springmvc_rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
</servlet>
<!-- rest 方式配置-->
<servlet-mapping>
<servlet-name>springmvc_rest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
//根据商品id查看商品信息rest接口
//@RequestMapping中指定restful方式的url中的参数,参数需要用{}包起来
//@PathVariable将url中的{}包起参数和形参进行绑定
@RequestMapping("/viewItems/{id}")
public @ResponseBody ItemsCustom viewItems(@PathVariable("id") Integer id) throws Exception{
//调用 service查询商品信息
ItemsCustom itemsCustom = itemsService.findItemsById(id);
return itemsCustom;
}
<!-- 静态资源 解析 -->
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:resources location="/img/" mapping="/img/**" />
标签:map exception 传递 实现 numbers tran cep 根据 解释
原文地址:https://www.cnblogs.com/haoworld/p/springmvcrestful-zhi-chi.html