私のJSP
<form method="POST" action="/searchClips">
<input type="text" name="streamer">
<input type="checkbox" name="player" value="hello">Hello
<input class="searchButton" type="image" src="/static/images/buttons/button_search.png"
alt="Search">
</form>
私のサーブレット
@Controller
public class HomeController {
@RequestMapping(value = {"/searchClips"}, method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String searchClips(@RequestBody Clip clip) {
System.out.println("hi");
System.out.println(clip);
return "index";
}
}
/searchClips に POST を実行する検索ボタンをクリックすると、415 応答コードが返されます。
Problem accessing /views/searchClips. Reason:
Unsupported Media Type
これが私のログです:
DispatcherServlet - DispatcherServlet with name 'dispatcher' processing POST request for [/searchClips]
RequestMappingHandlerMapping - Looking up handler method for path /searchClips
RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.projectName.controllers.HomeController.searchClips(com.projectName.models.Clip)]
DefaultListableBeanFactory - Returning cached instance of singleton bean 'homeController'
ExceptionHandlerExceptionResolver - Resolving exception from handler [public java.lang.String com.projectName.controllers.HomeController.searchClips(com.projectName.models.Clip)]: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded' not supported
DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
DispatcherServlet - Successfully completed request
誰が問題が何であるか知っていますか?