当前位置: 首页 > news >正文

商务网站建设ppt辽宁省建设部网站

商务网站建设ppt,辽宁省建设部网站,中国农业科技推广网,网站建设的知识点有哪些转自#xff1a; https://blog.csdn.net/cockroach02/article/details/82194126https://blog.csdn.net/cockroach02/article/details/82194126 一、当前现状 浏览器使用form提交信息的时候只支持GET和POST#xff0c;如果需要在浏览器上使用PUT和DELETE请求方式的话#…转自   https://blog.csdn.net/cockroach02/article/details/82194126https://blog.csdn.net/cockroach02/article/details/82194126 一、当前现状 浏览器使用form提交信息的时候只支持GET和POST如果需要在浏览器上使用PUT和DELETE请求方式的话只能使用欺骗的方式了SpringMvc提供了HiddenHttpMethodFilter类来提供支持请看代码 public class HiddenHttpMethodFilter extends OncePerRequestFilter {/** Default method parameter: {code _method} *///我们的隐藏字段name必须为_methodpublic static final String DEFAULT_METHOD_PARAM _method;private String methodParam DEFAULT_METHOD_PARAM;/*** Set the parameter name to look for HTTP methods.* see #DEFAULT_METHOD_PARAM*/public void setMethodParam(String methodParam) {Assert.hasText(methodParam, methodParam must not be empty);this.methodParam methodParam;}Overrideprotected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)throws ServletException, IOException {HttpServletRequest requestToUse request;if (POST.equals(request.getMethod()) request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) null) {String paramValue request.getParameter(this.methodParam);if (StringUtils.hasLength(paramValue)) {requestToUse new HttpMethodRequestWrapper(request, paramValue);}}filterChain.doFilter(requestToUse, response);}/*** Simple {link HttpServletRequest} wrapper that returns the supplied method for* {link HttpServletRequest#getMethod()}.*/private static class HttpMethodRequestWrapper extends HttpServletRequestWrapper {private final String method;public HttpMethodRequestWrapper(HttpServletRequest request, String method) {super(request);this.method method.toUpperCase(Locale.ENGLISH);}//通过继承方式对getMethod方法做了下改变就变成了PUT或者DELETE了Overridepublic String getMethod() {return this.method;}}} 二、配置步骤 1. web.xml !-- HTTP PUT Form --filterfilter-nameHiddenHttpMethodFilter/filter-namefilter-classorg.springframework.web.filter.HiddenHttpMethodFilter/filter-class/filterfilter-mappingfilter-nameHiddenHttpMethodFilter/filter-nameurl-pattern/*/url-pattern/filter-mapping 2. putform.jsp % page languagejava contentTypetext/html; charsetUTF-8 pageEncodingUTF-8% !DOCTYPE html html head meta http-equivContent-Type contenttext/html; charsetUTF-8 titleInsert title here/title /head bodyform methodPOST action%request.getServletContext().getContextPath()%/home/putformBodyinput typehidden name_method valuePUTp姓名/pinput typetext namename /br/p性别/pinput typetext namesex /br/p年龄/pinput typetext nameage /br/button typesubmit提交/button/form /body /html 3. putformBodycontroller方法 RequestMapping(pathhome/putformBody, methodRequestMethod.PUT, produces text/plain;charsetutf-8)ResponseBodypublic String putformBody(HttpServletRequest req, HttpServletResponse resp) {String name req.getParameter(name);String sex req.getParameter(sex);String age req.getParameter(age);return name: name ,sex: sex ,age: age;} 四、中间遇到的坑 1、拦截器的url-pattern必须配置为/*不能配置/否则不生效 2、为对中文支持避免乱码配置CharacterEncodingFilter必须为放在第一个否则即使是配置生效断点调试能进去但是依然中文乱码初学的朋友参考web.xml如下 ?xml version1.0 encodingUTF-8? web-app version3.0 xmlnshttp://java.sun.com/xml/ns/javaeexmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsddescriptioncockroach-springmvc-xml/descriptioncontext-paramparam-namecontextConfigLocation/param-nameparam-valueclasspath*:applicationContext.xml/param-value/context-paramservletservlet-namespringmvc/servlet-nameservlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-classinit-paramparam-namecontextConfigLocation/param-nameparam-value/WEB-INF/springmvc-servlet.xml/param-value/init-paramload-on-startup1/load-on-startup/servletservlet-mappingservlet-namespringmvc/servlet-nameurl-pattern//url-pattern/servlet-mapping!-- UTF-8 encoding --filterfilter-nameCharacterEncodingFilter/filter-namefilter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-classinit-paramparam-nameencoding/param-nameparam-valueUTF-8/param-value/init-paraminit-paramparam-nameforceEncoding/param-nameparam-valuetrue/param-value/init-param/filterfilter-mappingfilter-nameCharacterEncodingFilter/filter-nameurl-pattern/*/url-pattern/filter-mapping!-- HTTP PUT Form --filterfilter-nameHiddenHttpMethodFilter/filter-namefilter-classorg.springframework.web.filter.HiddenHttpMethodFilter/filter-class/filterfilter-mappingfilter-nameHiddenHttpMethodFilter/filter-nameurl-pattern/*/url-pattern/filter-mapping /web-app 3、SpringMvc以ResponseBody返回的时中文乱码demo学习的话可以配置下RequestMapping如下 RequestMapping(pathhome/putformBody, methodRequestMethod.PUT, produces text/plain;charsetutf-8) 五 参考连接 如何发送PUT请求和DELETE请求html 对 form 表单中 put,delete,patch的支持HTTP PUT请求时表单数据无法传递springmvc 明明到处都配置了编码为UTF-8可还是乱码
http://wiki.neutronadmin.com/news/191851/

相关文章:

  • 一个企业网站多少钱wordpress文章被采集
  • 做网站新手流程网站主域名
  • 建设工程公司企业简介安卓优化大师全部版本
  • 做软件下载网站怎么赚钱怎样提高网站的排名
  • 佛山网站设计联系方式北京seo关键词优化外包
  • 衡水建设投资集团网站网站建站时间查询
  • 内网门户网站 建设方案云南网站开发建设
  • vue做的网站html5手机网站开发经验
  • 济南做网站比较好的公司有哪些徐闻住房与城乡建设局网站
  • 电商网站网址大全超简单网站
  • 企业网站建设之域名篇河北建设工程信息网查看
  • 家政月嫂网站源码wordpress如何更改页面链接地址
  • 企业网站seo贵不贵温州网站建设首选龙诚互联
  • 建设网站的意义深圳旅游必去十大景点
  • 网站建设设计贵吗免费网络电视app
  • 做网站简历怎么写linux如何架设网站
  • 网站开发人员需要什么技能技术外包网站
  • 网站建设 好创办一个网站能挣钱吗
  • 重庆网站建设运营微信公众号开发软件
  • 郑州市网站开发快速开发网站
  • dw建设手机网站开发网站公司门户网站
  • 网站建设代码优化能用于制作网页的软件
  • 天柱县住房和城乡建设部网站沈阳市网站建设企业
  • 可以下载电影的网站怎么做北京微信公众号网站建设
  • 没有英文网站怎么做外贸漯河网站网站建设
  • 网站架构图用什么做成都网站建设索q479185700
  • 河南国基建设集团--官方网站怎样刷新网站
  • 适合seo优化的网站制作各种手艺培训班
  • 有没有做网站的高手政协网站信息化建设的作用
  • 北京城乡住房建设厅网站建设租房子的网站