0

I made a Post method in java restful services. When from front end user clicked on button for the first time there will be an error page showing the error message given below and I am getting this error only for the first time. Second time when user click it, it's working fine.

Whitelabel Error Page

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

This is my controller file:-

@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;
    }
1
  • Show your client code Commented Jan 27, 2017 at 9:21

1 Answer 1

3

As you can see from your error message :

Request method 'GET' not supported

Your html is connecting to your webservice by using a HTTP GET method instead of a POST method wanted by your request mapping :

 @RequestMapping(value="/classify",method = RequestMethod.POST)
Sign up to request clarification or add additional context in comments.

1 Comment

i mentioned method as post in my html file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.