使用springmvc时报错JSPs only permit GET POST or HEAD

两个地方需要注意:
第一处在web.xml文件中不要忘记配置

<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>

第二处是在方法开头加上注解@ResponseBody,代码如下所示

@RequestMapping(value="/testRest/{id}",method=RequestMethod.PUT)
    @ResponseBody
    public String testRestPut(@PathVariable Integer id){
        System.out.println("testRest Put:" + id);
        return SUCCESS;
    }

    @RequestMapping(value="/testRest/{id}",method=RequestMethod.DELETE)
    @ResponseBody
    public String testRestDelete(@PathVariable Integer id){
        System.out.println("testRest Delete:" + id);
        return SUCCESS;
    }

然后就成功了。

原文地址:https://www.cnblogs.com/liaoxiaolao/p/9994188.html

时间: 2024-08-30 09:10:07

使用springmvc时报错JSPs only permit GET POST or HEAD的相关文章

使用SpringMVC时报错HTTP Status 405 - Request method &#39;GET&#39; not supported

GET方法不支持.我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错. <script type="text/javascript"> $(function(){ $(".delete").click(function(){ var href = $(this).attr("href"); $("form").attr("action",href).submi

使用springmvc时报错HTTP Status 400 -

这个错误大多是因为,jsp的form表单提交的字段类型和后台接收字段类型不匹配造成的(例如,form中为String,后台接收为Integer). 我这里就是jsp表单中的日期数据没有写明类型,然后用Date接收就报错,把javabean中的Date类型换成String就没有错了. 原文地址:https://www.cnblogs.com/liaoxiaolao/p/10010337.html

SpringMVC在使用JSON时报错信息为:Content type &#39;application/json;charset=UTF-8&#39; not supported

直接原因是:我的(maven)项目parent父工程pom.xml缺少必要的三个jar包依赖坐标. 解决方法是:在web子模块的pom.xml里面添加springMVC使用JSON实现AJAX请求. <!--spring mvc-json依赖--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifact

新安装的soapui启动时报错及解决方法

今天新安装了soapui准备测试一下接口,结果安装成功后启动时报错:The JVM could not be started. The maximum heap size (-Xmx) might be too large 意思就是:Java虚拟机无法启动.Xmx可能太大 这时就需要将这个参数的值改小一点. 经过排查这个参数在soapui安装目录\bin\目录下的vmoptions配置文件中 将原来的值改为800,保存后启动成功

apache添加模块时报错:module status_module is built-in and can&#39;t be loaded

在使用cacti监控linux主机上的apache时,apache需要加载 mod_status.so 模块. 编辑httpd.conf,手动添加下行: LoadModule status_module modules/mod_status.so 在重启apache时报错如下: httpd: Syntax error on line 58 of /etc/httpd/httpd.conf: module status_module is built-in and can't be loaded

Mysql 插入时间时报错Incorrect datetime value: &#39;&#39; for column &#39;createtime&#39;

在网上找了很多方法总结如下: 1.MySQL驱动版本的问题.这种一般是在mYSQL版本更新了之后才会报错.解决方法在jdbc里添加"&useOldAliasMetadataBehavior=true" 2.可能是datetime的格式问题. datetime 以'YYYY-MM-DD HH:MM:SS'格式检索和显示DATETIME值.支持的范围为'1000-01-01 00:00:00'到'9999-12-31 23:59:59'TIMESTAMP值不能早于1970或晚于20

spark执行源码中的例子时报错

在运行spark源码时报错: Error:(45, 66) not found: type SparkFlumeProtocol  val transactionTimeout: Int, val backOffInterval: Int) extends SparkFlumeProtocol with Logging {                                                                 ^ ... Error:(25, 27) no

关闭多实例MySQL时报错

在MySQL刚装好两个实例的环境下,两实例启动后再关闭时报错: [[email protected] ~]# /data/3307/mysql stopStoping MySQL...Enter password: /application/mysql/bin/mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: Y

2个问题,解决tomcat启动一闪而过和运行tomcat/bin目录下的startup.bat时报错(the CATALINA_HOME environment variable is not defined correctly)

1.除手动使用开始菜单自启动或者程序启动TOMCAT时TOMCAT一闪而过,这时候是发生了错误,这时候我们打开BIN目录下的“startup.bat”文件,编辑,在结尾添加pause命名,这样在CMD下执行startup.bat时就会出错停止,这时候我们就知道是什么错误了. 2.运行tomcat/bin目录下的startup.bat时报错:the CATALINA_HOME environment variable is not defined correctly 碰到这个问题时的第一反应是添加