3

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]
0

2 Answers 2

1

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*")

Sign up to request clarification or add additional context in comments.

9 Comments

Already tried. Sorry I didn't specify. I added the log in the question.
Have you tried setting the controller to @RequestMapping("/test*")
That was nice suggestion but it's not working either :(.
Check the logs when the applications (startup/deploying) , spring scans the annotations and maps the bean to the url . usualy it prints all possible mapping based on url. that might give clue
The clean probably got rid of some old binaries. It might've been publishing old code.
|
0

Use wildcard in your Controller level @RequestMapping:

@RequestMapping("/test*")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.