我在java Restful services
中创建了一个Post方法。当前端用户第一次单击按钮时,将会出现一个错误页面,显示下面给出的错误消息,而我只是第一次收到此错误。当用户第二次单击它时,它工作正常。
白标错误页面
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Jan 27 03:51:51 EST 2017 There was an unexpected error (type=Method Not Allowed, status=405). Request method 'GET' not supported
这是我的 Controller 文件:-
@RequestMapping(value="/classify",method = RequestMethod.POST)
public @ResponseBody
List<List<HashMap<Object,Object>>> doClassify1( HttpServletRequest request,HttpServletResponse resp) {
try
{
System.out.println("Start of Classify");
prop = new Properties() ;
input = StwTagController.class.getClassLoader().getResourceAsStream("application.properties");
prop.load(input) ;
String rdurl = prop.getProperty("plmclassify") ;
String appId = request.getParameter("appId");
String appType = request.getParameter("appType");
String[] objectData = request.getParameterValues("objectData");
parentId = request.getParameter("parentObjectId");
String userId = request.getHeader("sm_ssoid");
obj = stwTagService.doClassify(appId,appType,objectData,parentId,userId );
resp.sendRedirect(rdurl+parentId);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return obj;
}
最佳答案
正如您从错误消息中看到的:
Request method 'GET' not supported
您的 html 使用 HTTP GET 方法而不是请求映射所需的 POST 方法连接到您的 Web 服务:
@RequestMapping(value="/classify",method = RequestMethod.POST)
关于Java spring boot webservices 和 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41890141/