我在尝试发送带有邮递员的某些参数的json对象的get get get get get get get get get get get get null'null'不支持的null'null'null'>
我应该获得该对象的ID接收JSON对象后的服务器端。
usercontroller:
package com.nust.QuizApplication.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.nust.QuizApplication.dao.UserDAO;
import com.nust.QuizApplication.model.User;
@Controller
@RequestMapping(value = "/users")
public class UserController {
@Autowired
private UserDAO userDao;
@RequestMapping(value = "/signup" ,method = RequestMethod.GET, consumes = "application/json" )
@ResponseBody
public int create(@RequestBody User user) {
int id = userDao.signupUser(user);
if(id>0)
return id;
else
return 0;
}
@RequestMapping(value = "/signin",method = RequestMethod.GET, consumes = "application/json" )
@ResponseBody
public boolean signinUser(@RequestBody User user) {
boolean check = userDao.signinUser(user);
if(check==true)
return true;
else
return false;
}
}
尝试使用@RequestParam
而不是@RequestBody
进行获取方法。喜欢
public boolean signinUser(@RequestParam(value = "user", required = true) User user)