request-mapping

Spring Mapping Url to Controller and View

房东的猫 提交于 2021-02-10 05:33:49
问题 I have the standard Spring 4.x files in Netbeans 8.0.2. I added a controller, RegisterController.java in the controllers -package. I also added one model, a User , with some basic information about the user. Next I made 2 .jsp files, Registration.jsp and RegistrationSuccess.jsp . Here is my RegisterController : @Controller @RequestMapping(value="/register") public class RegisterController { @RequestMapping(method=RequestMethod.GET) public String viewRegistration(Model model){ User user = new

Java handle invalid request Mapping urls including decodings

你说的曾经没有我的故事 提交于 2021-02-08 11:29:41
问题 in my apiController, I have @Controller @RequestMapping("api/v1/myservice") @Slf4j public class APIController { @RequestMapping(value = "/validAPI1", method = RequestMethod.GET) @ResponseBody public String validAPI1() { return "success"; } } I want to catch invalid incoming API requests, such as /api/v1/myservice/random124 , and this can be done by adding a method at the end: @RequestMapping(value = "/**", method = RequestMethod.GET) @ResponseBody public String handleInvalidAPIReq() { return

Spring mvc @RequestMapping on class level and method level 404 Status

两盒软妹~` 提交于 2021-02-05 08:21:06
问题 I know that there are lot of posts here with the same problem, but none of them seem to help me, so this will probably be a duplicate. Im creating a spring mvc application using Maven, i have only one controller with one method. When i put the request mapping annotation only on the class level the application works fine but when i put it on the class level and the method level and i send a request like this: localhost:8080/myapplication/planification/projet i get 404 error: HTTP Status 404 -

Spring MVC request Mapping Class level

我的梦境 提交于 2020-05-16 13:33:11
问题 I have made a small spring mvc app. In my controller i have 2 methods which returns the names of the jsp files in the web-inf folder. Now the application works perfectly, but if i try to add a url path it doesn't work. What i mean is something like this: @Controller @RequestMapping("/start") //if add this it doesn't work public class SalesController { @RequestMapping(value = "/greeting") public String sayGreeting(Model model) { model.addAttribute("greetingMsg", "Hello Spring"); return

Spring MVC request Mapping Class level

夙愿已清 提交于 2020-05-16 13:32:14
问题 I have made a small spring mvc app. In my controller i have 2 methods which returns the names of the jsp files in the web-inf folder. Now the application works perfectly, but if i try to add a url path it doesn't work. What i mean is something like this: @Controller @RequestMapping("/start") //if add this it doesn't work public class SalesController { @RequestMapping(value = "/greeting") public String sayGreeting(Model model) { model.addAttribute("greetingMsg", "Hello Spring"); return