HTTP 500作为对使用Spring控制器的HTTPPost请求的响应



我想在Post请求后响应我的Json对象,但当我这样做时,我得到了一个内部服务器HTTP 500


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.example.demo.beans.*;
import com.google.gson.JsonObject;
import programm.Manager;
@Controller
public class StudentRegistrationController {
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
public StudentRegistrationReply registerStudent(@RequestBody Student student) {
JsonObject t;
StudentRegistrationReply stdregreply = new StudentRegistrationReply();
StudentRegistration.getInstance().add(student);
//Manager m = new Manager();
t = Manager.solvingProcess(student.getContext(), student.getFilename());
stdregreply.setSolution(t);
return stdregreply;
}
}

在Manager中调用方法是没有问题的——它做了它应该做的一切。但在Postman,例如,我得到了一个HTTP500,我不明白为什么。

{
"timestamp": "2020-09-10T06:28:21.159+00:00",
"status": 500,
"error": "Internal Server Error",
"message": "",
"path": "/"
}

有人有主意吗?我的Manager类只将一个String格式化为JSONObject,里面有JSONArray,一切都很好。

我解决了这个问题。问题是我使用了google.gson中的JSON,httpresponse无法使用它。我将JSON从simple.JSON改为JSON,一切都很好。

相关内容

最新更新