标签:
springMVC实例一
请求中要包含name,但是不能包含age的写法params={"name","!age"}
当传age的时候
实例二:
先看删除和更新
HiddenHttpMethodFilter在Spring3.0中将post请求转换为put和delete请求,
查看HiddenHttpMethodFilter源码
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String paramValue = request.getParameter(this.methodParam); if ("POST".equals(request.getMethod()) && StringUtils.hasLength(paramValue)) { String method = paramValue.toUpperCase(Locale.ENGLISH); HttpServletRequest wrapper = new HttpMethodRequestWrapper(request, method); filterChain.doFilter(wrapper, response); } else { filterChain.doFilter(request, response); } }
public static final String DEFAULT_METHOD_PARAM = "_method"; private String methodParam = DEFAULT_METHOD_PARAM;
所以把name为_method的属性设置为DELETE和PUT就可以了
在web.xml中配置HiddenHttpMethodFilter,要写在DispatcherServlet前面
查询和保存:
运行页面:
标签:
原文地址:http://www.cnblogs.com/lonely-buffoon/p/5582556.html