Spring: Post request not reaching controller class

I am developing my first sample spring based project. Following is an excerpt from my dispatcher-servlet.xml .

<mvc:view-controller path="" view-name="test" />
<!-- location to scan for controllers -->
<context:component-scan base-package="com.test.demo.student.controller" />

I try to do a post to the following url, but it never seem to reach the corresponding controller class:

url: http://localhost:8080/TestProject/student/retrieveDetails

@Controller
@RequestMapping("student")
public class StudentController {

private final Logger logger = Logger.getLogger(StudentController.class);

@Autowired
public StudentService studentService;

public void setStudentService(StudentService studentService) {
    this.studentService = studentService;
}


 @RequestMapping(value = "/retrieveDetails", method = RequestMethod.POST)
public @ResponseBody String retrieveDetails(@RequestBody RetrieveStudentRequestBo retrieveStudentRequestBo,HttpServletRequest req,HttpServletResponse res) {

    logger.info("Entering StudentController.retrieveDetails()" );

input for post {"testID":"1"}

ERROR [400]
Bad Request 

is the response.

Why I get the 400 error though everything seem to be in place?

Answers


Please add slash before student:

@Controller
@RequestMapping("/student")
public class StudentController {
...
}

In addition, I expect that your build artifact will be TestProject.war since this is a parth of your path.


Need Your Help

Decode RTP stream (MPEG4) on Android

android video stream rtp

Hi everybody I hope you can help me out with this.