Tôi đang sử dụng khung công tác lò xo. Tôi có một webservice trong máy chủ Wepsphere như thếTrả lại JsonObject trong dịch vụ web an toàn vào mùa xuân
@RequestMapping (value="/services/SayHello2Me" , method=RequestMethod.GET, headers="Accept=application/json")
@ResponseBody
public JSONObject SayHello2Me(HttpServletRequest request) throws Exception {
String input = (String) request.getParameter("name");
String output = "hello " + input + " :)";
JSONObject outputJsonObj = new JSONObject();
outputJsonObj.put("output", output);
return outputJsonObj;
}
Khi tôi gọi nó là tạo Chrome như http://myserver/services/sayHello2Me?name= 'baris', nó sẽ trả tôi rằng lỗi:
Lỗi 404: SRVE0295E: Lỗi báo cáo: 404
Nếu tôi thay đổi annotions trong webservice của tôi như thế
@RequestMapping (value="/services/SayHello2Me")
@ResponseBody
public JSONObject SayHello2Me(HttpServletRequest request) throws Exception {
String input = (String) request.getParameter("name");
String output = "hello " + input + " :)";
JSONObject outputJsonObj = new JSONObject();
outputJsonObj.put("output", output);
return outputJsonObj;
}
.210
sau đó khi tôi gọi nó là tạo Chrome như http://myserver/services/sayHello2Me?name= 'baris', nó sẽ trả tôi rằng lỗi:
Lỗi 406: SRVE0295E: Lỗi báo cáo: 406
Có một vấn đề JSONObject vì nếu tôi return String insted của jsonobject trong cùng một webservice nó trả về cho tôi thành công.
Tôi làm cách nào để trả lại Jsonobject trong dịch vụ web an toàn vào mùa xuân?
Các ánh xạ không phù hợp. Khi bạn thay đổi nó giống nhau ở cả hai nơi thì có ổn không? – kamirru
Tất cả các ánh xạ đều khớp nhau. Tôi vừa nhầm lẫn vừa viết ở đây. Tôi đã cập nhật câu hỏi của mình. – neverwinter
Tại sao bạn không trả lại POJO? Jackson xử lý phần còn lại và tạo ra một chuỗi JSON. – mtyurt