启用HTTP POST请求我使用Spring启动,这里的行家依赖在春季启动
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
对于网页,我把文件放在src /主/资源/静态的。在那里我有我的html文件,js库(angular,jquery)和css文件。
我试图与角的HTTP请求POST(我也有做工精细的GET请求),但我得到这个
POST http://localhost:8080/xxxx/12/addEntry 405 (Method Not Allowed)
在响应头
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
X-Application-Context: application
Allow: HEAD, GET
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 09 Jul 2014 13:04:05 GMT
我意识到在Response中,allow不具有POST方法。
控制器
@RequestMapping(value = "/xxxx/{uid}/addEntry", method = RequestMethod.POST)
@ResponseBody
public String createEntry(@PathVariable String uid, @RequestBody String form) {
System.out.println(form);
return "index.html";
}
你确定Spring看到控制器吗?该控制器的其他方法是否工作? – axtavt
@axtavt谢谢你的回答。 GET请求正在工作。 – agusgambina
如果您尝试删除'@RequestBody字符串表单',该怎么办? – axtavt