Announcement Announcement Module
Collapse
No announcement yet.
What sort of contrller and/or view mapping is needed to just deliver a jsp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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
    Code:
    ...\context_name\app_name?command=_some_command_name_&param=....
    The request mapping
    Code:
    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:
    Code:
       <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" />
        </bean>
    I have been notified that this system will also have to handle requrests of the form
    Code:
    .../context_name/*.jsp
    . This request just delivers the jsp. For example, there will be a login.jsp so the URL would be
    Code:
    .../context_name/login.jsp
    .

    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,
    bils

    I just tried creating another controller and giving it the mapping:
    Code:
     @RequestMapping(value="/login.jsp")
    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
    Code:
    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 com.ar
    tificialmed.dbconnect.controller.LoginController.serviceRequest(javax.servlet.ht
    tp.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework
    .ui.Model)
    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?

    Thanks,
    bils

    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, 03:52 PM. Reason: more iinformation
Working...
X