免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
Spring MVC過(guò)濾器-HiddenHttpMethodFilter
瀏覽器form表單只支持GET與POST請(qǐng)求,而DELETE、PUT等method并不支持,spring3.0添加了一個(gè)過(guò)濾器,可以將這些請(qǐng)求轉(zhuǎn)換為標(biāo)準(zhǔn)的http方法,使得支持GET、POST、PUT與DELETE請(qǐng)求,該過(guò)濾器為HiddenHttpMethodFilter。

        HiddenHttpMethodFilter的父類(lèi)是OncePerRequestFilter,它繼承了父類(lèi)的doFilterInternal方法,工作原理是將jsp頁(yè)面的form表單的method屬性值在doFilterInternal方法中轉(zhuǎn)化為標(biāo)準(zhǔn)的Http方法,即GET,、POST、 HEAD、OPTIONS、PUT、DELETE、TRACE,然后到Controller中找到對(duì)應(yīng)的方法。例如,在使用注解時(shí)我們可能會(huì)在Controller中用于@RequestMapping(value = "list", method = RequestMethod.PUT),所以如果你的表單中使用的是<form method="put">,那么這個(gè)表單會(huì)被提交到標(biāo)了Method="PUT"的方法中。

        需要注意的是,由于doFilterInternal方法只對(duì)method為post的表單進(jìn)行過(guò)濾,所以在頁(yè)面中必須如下設(shè)置:

  1. <form action="..." method="post">  
  2.         <input type="hidden" name="_method" value="put" />  
  3.         ......  
  4. </form>  

        而不是使用:

  1. <form action="..." method="put">  
  2.         ......  
  3. </form>  

        同時(shí),HiddenHttpMethodFilter必須作用于dispatcher前,所以在web.xml中配置HiddenHttpMethodFilter時(shí),需參照如下代碼:

  1.       <filter>    
  2.               <filter-name>HiddenHttpMethodFilter</filter-name>    
  3.               <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>    
  4.       </filter>    
  5.       <filter-mapping>    
  6.               <filter-name>HiddenHttpMethodFilter</filter-name>    
  7.               <servlet-name>spring</servlet-name>    
  8.       </filter-mapping>  
  9.       <servlet>  
  10. <servlet-name>spring</servlet-name>  
  11. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  12. <init-param>  
  13.     <param-name>contextConfigLocation</param-name>  
  14.     <param-value>classpath:dispatcher.xml</param-value>  
  15. </init-param>  
  16. lt;/servlet>  
  17.       <servlet-mapping>  
  18. <servlet-name>spring</servlet-name>  
  19. <url-pattern>*.html</url-pattern>  
  20. lt;/servlet-mapping>  

        同樣的,作為Filter,可以在web.xml中配置HiddenHttpMethodFilter的參數(shù),可配置的參數(shù)為methodParam,值必須為GET,、POST、 HEAD、OPTIONS、PUT、DELETE、TRACE中的一個(gè)。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Spring MVC 學(xué)習(xí)筆記(二):@RequestMapping用法詳解
通過(guò)HttpServletRequestWrapper(裝飾模式的應(yīng)用)增強(qiáng)HttpServletRequest的功能,過(guò)濾GET請(qǐng)求編碼
SpringMVC添加支持Http的delete、put請(qǐng)求
SpringMVC控制器接收不了PUT提交的參數(shù)的解決方案
Servlet中的過(guò)濾器(攔截器)Filter與監(jiān)聽(tīng)器Listener的作用和區(qū)別
spring+hibernate整合
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服