- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我尝试 @RequestMapping(value = "/test", method = RequestMethod.POST)
但出错了
代码是
@Controller
public class HelloWordController {
private Logger logger = LoggerFactory.getLogger(HelloWordController.class);
@RequestMapping(value = "/test", method = RequestMethod.POST)
public String welcome() {
logger.info("Spring params is welcome");
return "/WEB-INF/jsp/welcome";
}
}
web.xml 是
<servlet>
<description>This is Spring MVC DispatcherServlet</description>
<servlet-name>SpringMVC DispatchServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<description>SpringContext</description>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<servlet-mapping>
<servlet-name>SpringMVC DispatchServlet</servlet-name>
<url-pattern>/</url-pattern>
而springmvc.xml是
index.jsp 是
<form action="<%=request.getContextPath() %>/test" method="post">
<input type="submit" value="submit">
</form>
我输入提交按钮浏览器出错
HTTP Status 405 - Request method 'GET' not supported type Status report
message Request method 'GET' not supported
description The specified HTTP method is not allowed for the requested resource (Request method 'GET' not supported).
最佳答案
method = POST
如果您将表单“发布”到 url/test 将起作用。
如果你在浏览器的地址栏中输入一个url然后回车,它总是一个GET
请求,所以你必须指定POST请求。
Google for HTTP GET
和 HTTP POST
(还有其他几个,例如 PUT DELETE)。它们都有各自的含义。
关于java - 为什么不支持 SpringMVC 请求方法 'GET'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3333611/
基于SpringBoot版本如下: org.springframework.boot spring-boot-starter-parent 2.5.2
@RestController public class TestController { @GetMapping("/download") public ResponseEntit
概述 记得之前跟前端同事联调接口的时候,后端SpringMVC需要接收数组类型的参数,然后跟前端说需要传数组类型过来。后来前端童鞋传了数组,但是后端接收不成功,联调失败。那时候由于时间关系没有仔细研究
web.xml 片段: contextConfigLocation /WEB-INF/applicationContext-security.xml a
目录 相关准备 功能清单 具体功能:访问首页 ①配置view-controller ②创建页面
Spring mvc是一个非常轻量的mvc框架,注解可以大大减少配置,让请求的拦截变得比较简单。这次记录下@RequestBody 注解接收参数尤其是数组参数的用法。 关于容器的配置不再多说,这里
目录 SpringMVC默认处理的几种异常 @ResponseStatus 异常处理的顺序 自定义异常类(SpringMVC的异常处理)
目录 SpringMVC 接收前端传递的参数四种方式 @RequestParam 获取注解 @PathVariable获取注解 Sp
目录 @PathVariable的用法解析 问题描述 解析过程 动态参数使用@PathVariable
目录 SpringMVC @NotNull校验不生效 加了两个依赖问题解决 @NotNull注解失效原因之一 Lo
springmvc―handlermapping三种映射 handlermapping负责映射中央处理器转发给controller的映射策略,简单说就是控制中央处理器的请求触发哪一个control
目录 使用ModelAndView向request域对象共享数据 使用Model向request域对象共享数据 使用map向request域对象共享数据
整合SSM 环境要求 环境: IDEA MySQL5.7.19 Tomcat9 Maven3.6 要求: 需要熟练掌握MySQL数据库,Spring,Ja
目录 1、SpringMVC简介 2、工作流程与介绍 3、代码截图 以下组件通常使用框架提供实现: 1、Di
简介 SpringMVC的处理器拦截器类似于Servlet开发中的过滤器Filter,用于对处理器进行预处理和后处理。开发者可以自己定义一些拦截器来实现特定的功能。 过滤器
背景 举个例子,出现中文乱码的例子:提交表单的时候。 表单 ?
请求进入DispatcherServlet的doDispatch后,获取HandlerMethod。然后根据HandlerMethod来确认HandlerApapter,确认后执行HandlerAd
实现需求: 1.用户未登录,跳转到登录页,登录完成后会跳到初始访问页。 2.用户自定义处理(如需要激活),跳转到激活页面,激活完成后会跳到初始访问页。 使用到的框架 springmvc 的拦
为了实现用户登录拦截你是否写过如下代码呢? 1. 基于Filter ?
springmvc dao层和service层的区别 首先解释面上意思,service是业务层,dao是数据访问层 这个问题我曾经也有过,记得以前刚学编程的时候,都是在service里直接调用d
我是一名优秀的程序员,十分优秀!