Can I use EL to specify my application context path on my Spring Controller using something like @RequestMapping("${pageContext.request.contextPath}")? Actually, I get an 404 error. So my question is how to map controller on context root?
I presume @RequestMapping("/") cannot do the job when app is not alone on the server, and url looks like:
http://localhost:8080/myapp/mypage
@Controller
@RequestMapping("${pageContext.request.contextPath}")
public class MainController {
@RequestMapping("/")
public ModelAndView index() {
}
}
PS: I've already added the app path prefix into every single url on my JSPs, like <form class="form-inline" role="form" action="${pageContext.request.contextPath}/search" method="post">. Now I need to make the same trick for my Spring Controllers to make it work when... wheather app deployed as ROOT app or as "just another app on this server".
DispatcherServletis mapped to/. The Servlet container will already have resolved that your app's Servlet should be invoked.