web--8.restful-2.配置

    xiaoxiao2021-03-25  146

    参看博客:https://blog.csdn.net/chenxiaochan/article/details/73716617

    https://blog.csdn.net/chenxiaochan/article/details/52988323

    1      配置

    1.1  web.xml配置—rest风格

     

    1.2  web.xml配置—请求转换

    HiddenHttpMethodFilter,HttpPutFormContentFilter

        浏览器 form 表单只支持 GET 与POST 请求,而DELETE、PUT 等 method 并不支

    持,Spring3.0 添加了一个过滤器,可以将这些请求转换为标准的 http 方法,使得支持 GET、POST、PUT 与DELETE 请求。

    <!-- 配置 org.springframework.web.filter.HiddenHttpMethodFilter: 可以把 POST 请求转为 DELETE 或 POST 请求 --> <!-- 4、使用Rest风格的URI,将页面普通的post请求转为指定的delete或者put请求 --> <filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>HttpPutFormContentFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> <filter-mapping> <filter-name>HttpPutFormContentFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

    参看博客:https://blog.csdn.net/chenxiaochan/article/details/73716617

    https://blog.csdn.net/chenxiaochan/article/details/52988323

    1      配置

    1.1  web.xml配置—rest风格

     

    1.2  web.xml配置—请求转换

    HiddenHttpMethodFilter,HttpPutFormContentFilter

        浏览器 form 表单只支持 GET 与POST 请求,而DELETE、PUT 等 method 并不支

    持,Spring3.0 添加了一个过滤器,可以将这些请求转换为标准的 http 方法,使得支持 GET、POST、PUT 与DELETE 请求。

    <!-- 配置 org.springframework.web.filter.HiddenHttpMethodFilter: 可以把 POST 请求转为 DELETE 或 POST 请求 --> <!-- 4、使用Rest风格的URI,将页面普通的post请求转为指定的delete或者put请求 --> <filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>HttpPutFormContentFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> <filter-mapping> <filter-name>HttpPutFormContentFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

    转载请注明原文地址: https://ju.6miu.com/read-6011.html

    最新回复(0)