I'm sure this is a question with noob, and I spent most of the hours traverse stackoverflow for an answer, but no one seems to have my case, so we go ...
I have a new webapp that uses Spring MVC. Most applications (99%) are pure REST, so it does not have a "representation" as such, but simply sends JSON back to the wire or sends an alternative HTTP status for errors, etc.
The exception is the login page, which must be the actual JSP, but somehow the configuration that I use to map the REST controllers leaves me in a state where regular JSP mappings fail.
Here is what I have:
In my dispatcher servlet configuration, the relevant parts are:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
In my attempts to make it work, I also added a mapping to the "HomeController", which is currently just being redirected to my JSP access:
<bean name="/" class="com.somepackage.HomeController"/>
Now in web.xml I have:
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-dispatcher-servlet.xml
</param-value>
</context-param>
This works fine for my RESTful controllers, which look like this:
@Controller
@RequestMapping(value = "/api/user")
public class BlahBlahController {...
My "HomeController", which looks something like this:
@Controller
@RequestMapping(value = "/")
public class HomeController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
return new ModelAndView("login");
}
}
IS starts when I press the "/" url, but I get this error in the logs:
WARNING: No mapping found for HTTP request with URI [/WEB-INF/pages/login.jsp] in DispatcherServlet with name 'spring-dispatcher'
Now I get what he says, he doesnβt know how to allow /WEB-INF/pages/login.jsp(this page really exists), but I am fixated on how I need to change everything to make it work.
I'm a little confused about how it should work. Anyone got any clues?
Thank.