Spring @RequestMapping on controller

Ludovic Guillaume

I'm using Spring MVC 3.1.3.

I'd like to do the same as the example shown in the documentation. @RequestMapping on the controller and a 'root' method.

But Spring does not handle correctly.

Here's my code :

@Controller
@RequestMapping("/test")
public class TestController {
    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public String list() {
        return "test";
    }
}

When I try http://localhost/test-project/test I get a 404 Not Found but it's working when I use http://localhost/test-project/test/.

Does anyone know how I can fix this ?

Thanks,

Smoky

EDIT:

Here's the log :

16:13:36,085 | DEBUG | RequestMappingHandlerMapping:209 | Looking up handler method for path /test
16:13:36,087 | DEBUG | RequestMappingHandlerMapping:219 | Did not find handler method for [/test]
david99world

Change the method requestMapping tag on the method to...

@RequestMapping(value = {"", "/", "/list"}, method = RequestMethod.GET)

Edit addition from comment :

Have you tried setting the controller to @RequestMapping("/test*")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring @RequestMapping on controller

From Dev

Multiple @RequestMapping for a method in controller class in Spring MVC

From Dev

Coding to an interface on a Spring Controller method with @RequestMapping

From Dev

Spring MVC 4.2.4 / Controller with RequestMapping("/**") and static resources

From Dev

set @RequestMapping value to return spring controller

From Dev

How to return Controller instead of View in RequestMapping in Spring?

From Dev

Duplicate Spring Controller method @RequestMapping for Restful

From Dev

What is the difference between @Controller and @RequestMapping in Spring MVC?

From Dev

Spring Boot REST Controller Test with RequestMapping of Properties Value

From Dev

Spring MVC: Controller RequestMapping working, but return always gives a 404

From Dev

How to optimize my code in Spring MVC Controller using @RequestMapping?

From Dev

Junit Test cases for Spring MVC controller to check @PathVariable parameters in @RequestMapping

From Dev

Spring @RequestMapping

From Dev

Junit Test cases for Spring MVC 4 controller to check @PathVariable parameters in @RequestMapping

From Dev

how to call spring controller @RequestMapping from another action method passing form object along with the call

From Dev

How do you get RequestMapping request in AOP advice from a Spring controller?

From Dev

Why does Spring's HandlerInterceptorAdapter is called twice only when my controller has @RequestMapping (produces = ...)?

From Dev

Spring MVC RequestMapping

From Dev

Spring @RequestMapping absolute path

From Dev

Spring: @RequestMapping with multiple values

From Dev

Matching anything in Spring RequestMapping

From Dev

Spring @RequestMapping Nested Behavior

From Dev

Spring @RequestMapping log messages?

From Dev

spring RequestMapping 404 status

From Dev

Spring MVC and AngularJS @RequestMapping

From Dev

Grails 3 and Spring @RequestMapping

From Dev

Spring RequestMapping wildcard and suffix

From Dev

Spring RequestMapping conflicts

From Dev

Spring AOP and RequestMapping Annotations

Related Related

  1. 1

    Spring @RequestMapping on controller

  2. 2

    Multiple @RequestMapping for a method in controller class in Spring MVC

  3. 3

    Coding to an interface on a Spring Controller method with @RequestMapping

  4. 4

    Spring MVC 4.2.4 / Controller with RequestMapping("/**") and static resources

  5. 5

    set @RequestMapping value to return spring controller

  6. 6

    How to return Controller instead of View in RequestMapping in Spring?

  7. 7

    Duplicate Spring Controller method @RequestMapping for Restful

  8. 8

    What is the difference between @Controller and @RequestMapping in Spring MVC?

  9. 9

    Spring Boot REST Controller Test with RequestMapping of Properties Value

  10. 10

    Spring MVC: Controller RequestMapping working, but return always gives a 404

  11. 11

    How to optimize my code in Spring MVC Controller using @RequestMapping?

  12. 12

    Junit Test cases for Spring MVC controller to check @PathVariable parameters in @RequestMapping

  13. 13

    Spring @RequestMapping

  14. 14

    Junit Test cases for Spring MVC 4 controller to check @PathVariable parameters in @RequestMapping

  15. 15

    how to call spring controller @RequestMapping from another action method passing form object along with the call

  16. 16

    How do you get RequestMapping request in AOP advice from a Spring controller?

  17. 17

    Why does Spring's HandlerInterceptorAdapter is called twice only when my controller has @RequestMapping (produces = ...)?

  18. 18

    Spring MVC RequestMapping

  19. 19

    Spring @RequestMapping absolute path

  20. 20

    Spring: @RequestMapping with multiple values

  21. 21

    Matching anything in Spring RequestMapping

  22. 22

    Spring @RequestMapping Nested Behavior

  23. 23

    Spring @RequestMapping log messages?

  24. 24

    spring RequestMapping 404 status

  25. 25

    Spring MVC and AngularJS @RequestMapping

  26. 26

    Grails 3 and Spring @RequestMapping

  27. 27

    Spring RequestMapping wildcard and suffix

  28. 28

    Spring RequestMapping conflicts

  29. 29

    Spring AOP and RequestMapping Annotations

HotTag

Archive