Spring MVC method POST no supported
首先:一些隐含的知识点要知道
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的更多相关文章
- Supported method argument types Spring MVC
Supported method argument types The following are the supported method arguments: Request or respons ...
- Spring MVC出现POST 400 Bad Request &405 Request method 'GET' not supported
首先描述一下出现错误的情景: 我刚学springmvc,想做一个登录界面的东西.然后试着写了一个controller如下: @RequestMapping(value = "/login&q ...
- 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控制台 ...
- html form method 属性不支持put,delete请求方式,以及开启spring mvc的rest的方式
1.加上隐藏域解决form method 不支持put,delete的请求方式的问题 2.配置spring mvc HiddenHttpMethodFilter过滤器实现对put和delete请求方式 ...
- 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 ...
- Spring MVC 基于Method的映射规则(注解版)
在Restful风格的web开发中,根据不同的请求方法使用相应的控制器处理逻辑成为核心需求,下面就看看如何在Spring MVC中识别不同的请求方法. 请求方法 在Http中,请求的方法有很多种,最常 ...
- spring MVC controller中的方法跳转到另外controller中的某个method的方法
1. 需求背景 需求:spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参数跳转,页面也能显示. 本来以为挺简单的一 ...
- oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法
报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description> ...
- Spring Boot Request method DELETE not supported
1: 开启HiddenHttpMethodFilter 最新版本的spring boot 默认不开启 restful 分割api @Bean @ConditionalOnMissingBean({Hi ...
随机推荐
- unity position 记录
localPosition为自身矩形中心点(Pivot)与其父节点矩形中心点(Pivot)的相对位置坐标,与自身锚点(Anchors)无关.anchoredPosition为矩形中心点(Pivot)与 ...
- APP开发---后台设计
想了好久才准备写博客的,希望能对我自己和大家都有帮助! 话不多说,直接正题! ------------------------------------------------------------- ...
- SQL批量插入数据【万级】
1.每4000条插入一次 for (int i = 0; i < dt.Rows.Count; i++) { IsTBProductForStockInfo model = new IsTBPr ...
- 蜂鸟E203系列——Linux下运行hello world例程
欲观原文,请君移步 创建程序 在 -/hbird-e-sdk-master/software 路径下创建一个"helloworld"中文件夹 在 -/hbird-e-sdk-mas ...
- 微信支付之获取code
微信支付之获取code, 1:访问下面的连接(自己拼) 2:去回调地址里拿code https://open.weixin.qq.com/connect/oauth2/authorize?appid= ...
- typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...
如上贴出了:错误信息和错误代码. 这个问题困扰了自己两天,报错大概是说输入的数据和接受的格式不一样,不能作为tensor. 后来问了大神,原因出在tf.reshape(),因为网络训练时用placeh ...
- RAC环境上搭建DG
首先RAC要确实是开归档的状态archive log list;如果是非归档状态,需要执行下面几步srvctl stop database -d +数据库实例名 关闭数据库--节点1(要做DG主库的) ...
- VMware虚拟机网络配置详解
VMware网络配置:三种网络模式简介 安装好虚拟机以后,在网络连接里面可以看到多了两块网卡: 其中VMnet1是虚拟机Host-only模式的网络接口,VMnet8是NAT模式的网络接口,这些后面会 ...
- react实战 : 用矩阵思想做一个自适应布局容器组件
需求是这样的. 有一个需要显示若干方块型元素的小区域 数量比较少的时候显示一排 数量比较多的时候显示两排 用 grid 不好,因为当数量为奇数的时候需要两排里面的元素都乖乖的居中显示. 用 flex ...
- 不懂DevOps!他在升职加薪的那天下午,提出了离职
不久前我们一个已毕业的学员向班主任老师分享了前几天他遇到的一件事: 一个许久未联系他的朋友突然打电话给他,寒暄了几句后突然说,想来北京找工作,问能不能帮忙给介绍一些工作. 在接下来的通话中,我们学员了 ...