Announcement Announcement Module
No announcement yet.
What sort of contrller and/or view mapping is needed to just deliver a jsp Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • What sort of contrller and/or view mapping is needed to just deliver a jsp

    I'm working on a Spring MVC system that, up to now, handled requests that did some processing and returned a success or failure view. A single controller handles all of the work because the URLs are of the form
    The request mapping
    value= "\app_name"
    routes all requests to the single controller. There is a class for each command and a command factory is used by the controller to get the appropriate class and call a single method which returns a view name.

    I currently have this view resolver that handles the jsps that are associated with each command:
       <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
     	<property name="order" value="1" />
            <property name="prefix" value="/WEB-INF/jsp/" />
            <property name="suffix" value=".jsp" />
    I have been notified that this system will also have to handle requrests of the form
    . This request just delivers the jsp. For example, there will be a login.jsp so the URL would be

    I'm not sure how to handle these direct jsp requests. Do I need to create a separate controller to handle this type of request? If so, how do I specify the request mapping since the jsp name, e.x. login.jsp, is really all I've got to route with.

    Thanks for any help or advice,

    I just tried creating another controller and giving it the mapping:
    When I send a request of the form: /context/login.jsp I get an HTTP 404, resource not found. Also, there is no logging from the new controller so it appears that the request never made it to the controller which implies that the mapping was not applied. However, in the log file I see
    8904 [pool-2-thread-1] INFO  org.springframework.web.servlet.mvc.method.annotati
    on.RequestMappingHandlerMapping  - Mapped "{[/login.jsp],methods=[],params=[],he
    aders=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String
    I'm more confused than ever. The mapping for the new controller seems so similar to the existing controller that it is hard to figure out what might be incorrect.

    Can anyone spot what might be going on here?


    I have continued to work with this problem and I've observed that the period in login.jsp seems to be the problem both for mapping and for the url that is sent to the controller. If I use 'login' or 'XXX' as the mapping the controller gets invoked and login.jsp is returned. If I map 'login.jsp' I get a 404 if I map as 'login*', URLs ending with 'login' and 'loginXXX' both invoke the controller but 'login.jsp' still produces a 404. I have read through a lot of Spring docs on request mapping and have not seen an explanation for this behavior.

    Does anyone know what is going on here? It looks like it is not possible to map to a pattern that contains a period.

    Thanks, bils
    Last edited by bills; Jan 21st, 2013, 02:52 PM. Reason: more iinformation