首先:一些隐含的知识点要知道

POST 的不支持对静态资源的访问[默认情况下是这样,个人不太了解,仅总结大概思路],如果是post 而响应的是个静态资源,则很多情况下出现这种错误

因此在使用POST应尽量避免响应的是静态资源。

还有个知识点:使用Ajax 时候,不要响应 forward 或 redirect 因为基本上是不跳转的,无效的。Ajax 接受的只是返回的数据,只可能把本来该跳转后的网页弄成数据发送给你。

当然如果仅需要支持GET 在SpringMVC中想得到静态页面的响应需要以下配置

 <mvc:annotation-driven/>
<mvc:resources mapping="/source/**" location="/source/"/>
<mvc:resources mapping="/html/**" location="/html/"/>

如果要GET POST都可以把静态资源作为响应,则需要如下配置,可以自定义请求类型

<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/html/**" value="myResourceHandler"/>
<entry key="/source/**" value="myResourceHandler"/>
</map>
</property>
<property name="order" value="0"/>
</bean> <bean id="myResourceHandler" name="myResourceHandler"
class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
<property name="locations">
<list>
<value>/html/</value>
<value>/source/</value>
</list>
</property>
<property name="supportedMethods">
<list>
<value>GET</value>
<value>HEAD</value>
<value>POST</value>
</list>
</property>

Spring MVC method POST no supported的更多相关文章

  1. Supported method argument types Spring MVC

    Supported method argument types The following are the supported method arguments: Request or respons ...

  2. Spring MVC出现POST 400 Bad Request &405 Request method 'GET' not supported

    首先描述一下出现错误的情景: 我刚学springmvc,想做一个登录界面的东西.然后试着写了一个controller如下: @RequestMapping(value = "/login&q ...

  3. Spring boot: Request method 'DELETE' not supported, Request method 'PUT' not supported, Request method 'POST' not supported

    GET,POST,PUT,DELETE, Spring都支持,不要怀疑Spring, 一定是前端发送的rest 请求和后端的响应不匹配, 查找原因以及解决办法, 很简单 用chrome打开F12控制台 ...

  4. html form method 属性不支持put,delete请求方式,以及开启spring mvc的rest的方式

    1.加上隐藏域解决form method 不支持put,delete的请求方式的问题 2.配置spring mvc HiddenHttpMethodFilter过滤器实现对put和delete请求方式 ...

  5. ajax使用向Spring MVC发送JSON数据出现 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported错误

    ajax使用向Spring MVC发送JSON数据时,后端Controller在接受JSON数据时报org.springframework.web.HttpMediaTypeNotSupportedE ...

  6. Spring MVC 基于Method的映射规则(注解版)

    在Restful风格的web开发中,根据不同的请求方法使用相应的控制器处理逻辑成为核心需求,下面就看看如何在Spring MVC中识别不同的请求方法. 请求方法 在Http中,请求的方法有很多种,最常 ...

  7. spring MVC controller中的方法跳转到另外controller中的某个method的方法

    1. 需求背景     需求:spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参数跳转,页面也能显示. 本来以为挺简单的一 ...

  8. oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法

    报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description> ...

  9. Spring Boot Request method DELETE not supported

    1: 开启HiddenHttpMethodFilter 最新版本的spring boot 默认不开启 restful 分割api @Bean @ConditionalOnMissingBean({Hi ...

随机推荐

  1. 线下---复习day03

    目录 django回顾 1 web应用,http协议,web框架 2 django请求生命周期 3 路由控制 4 视图层 5 模板层 6 模型层 django回顾 1 web应用,http协议,web ...

  2. java学习第二天 20207/7

    一. 1.对传参进行了了解 2. 2.java的变量命名与c/c++有些不同在java中有¥,字母,下划线和数字,同样不可以是数字开头. java的布尔型为boolean 各个数据类型的信息: 注意: ...

  3. MySQL后记

    MySQL后记 这篇博客的目的是记录一些容易被忽略的MySQL的知识点,以及部分pymysql模块的注意点. MySQL中的DDL与DML DDL:数据定义语言(Data Definition Lan ...

  4. 机器学习实战基础(十九):sklearn中数据集

    sklearn提供的自带的数据集   sklearn 的数据集有好多个种 自带的小数据集(packaged dataset):sklearn.datasets.load_<name> 可在 ...

  5. 阅读手札 | 手把手带你探索『图解 HTTP』

    前言 本文已经收录到我的 Github 个人博客,欢迎大佬们光临寒舍: 我的 Github 博客 学习清单: 一.网络基础 TCP/IP 通常使用的网络(包括互联网)是在 TCP/IP 协议族的基础上 ...

  6. GPO - Backup and Restore

    Backup the GPO to a second server is very important. Restore a GPO if necessary. Note: WMI filter an ...

  7. JAVA 面向对象 三大特征:继承

    什么是继承 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中,那么多个类无需再定义这些属性和行为,只要继承那个类即可. 多个类可以称为子类,单独这个类称为父类.超类或者基类. 子类可以直接访 ...

  8. vue组件库用markdown生成文档

    前言: 开发vue组件库需要提供组件的使用文档,最好是有渲染到浏览器的demo实例,既能操作又能查看源代码.markdown作为常用的文档编写载体,如果能在里面直接写vue组件,同时编写使用说明就再好 ...

  9. Git的忽略文件

    *.iml.gradle.idea/local.properties/.idea/workspace.xml/.idea/libraries.DS_Store/build/captures.exter ...

  10. 把若依管理系统部署到Linux

    一.前言 1.非常感谢若依作者为大家提供的非常优质的开源web项目,非常感谢!!! 2.若依官方文档:http://doc.ruoyi.vip/ruoyi/ 3.若依官方链接: 1)若依管理系统官方体 ...