【发布时间】:2017-03-11 09:12:24
【问题描述】:
@ResponseBody
@RequestMapping(value = {"apiRequest"}, method = {RequestMethod.POST})
public String contestApiSignUp(HttpServletRequest req) throws JSONException {
try {
String username = req.getParameter("username");
String firstname = req.getParameter("firstname");
String lastname = req.getParameter("lastname");
String password = req.getParameter("password");
String phone = req.getParameter("phone");
这里我得到的值都是空的。那就是用户名=null,名字=null...
我正在使用这些值发送帖子请求 http://localhost:8080/apiRequest.htm
username = Subhajit
firstname = Subha
...
像这样。
但是当我使用相同的代码时,
@RequestMapping(value = {"apiRequest"}, method = {RequestMethod.GET})
使用 GET 而不是 POST 然后我得到正确的值。
【问题讨论】:
-
你能用标题显示你的确切发布请求吗
标签: spring post request-mapping