@RequestMapping Request Path Mapping, assuming that the label is at the class level of a controller, the access to the method under such a path is accompanied by its configured path. Most often used is labeled on the method. Indicates which detailed method to accept processing a request.
The following two ways can be passed from the URL, but the applicability of the other way is higher, when the reference is included in Chinese, assuming that the first way to pass the parameters, often the number of participants before the controller has been encoded (for example: after Utf-8 encoding, The original number of references to be transmitted will be%+ab ... CD this way), and then the Controller accepts such a request, it simply cannot resolve the request should go to that business method. Then there will be a common 404 problem.
。。
Package Com.test.jeofey.web;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;import Org.springframework.stereotype.controller;import Org.springframework.web.bind.annotation.pathvariable;import org.springframework.web.bind.annotation.RequestMapping; @Controller @requestmapping ("/path") public class TestController {///first-pass access address such as: http: domain name/path/method1/keyword.html@requestmapping ("Method1/{keyword}") public String Getzhishidetaildata (@PathVariable ("KeyWord") string keyword,httpservletrequest request, HttpServletResponse Response) {System.out.println (KeyWord); return "V1/detail";} Another way to access addresses such as: http: domain name/path/method2.html?key=keyword@requestmapping ("METHOD2") Public String Getcommondata ( HttpServletRequest request, HttpServletResponse response) {String keyword= request.getparameter ("key"); System.out.println (KeyWord); return "V1/common";}}
Spring Annotations @requestmapping Request Path mapping problem