web.xml配置
<!-- spring mvc 拦截器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- 配置spring resetful -->
<servlet>
<servlet-name>springRESTful</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/spring-mvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springRESTful</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
springmvc.xml配置
<!-- 使用RESTFul风格时对静态资源的访问 -->
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/css/" mapping="/css/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
接着在ACTION里配置
//id跟是把页面传来的数据匹配绑定到参数上
@RequestMapping("/gUserInfo/{id}")
public @ResponseBody TUserinfo gUserinfo(@PathVariable("id") String user) throws Exception {
TUserinfo u = userService.findByUserName(user);
return u;
}
页面上直接访问xxx/gUserInfo/id就可以了