Announcement Announcement Module
Collapse
No announcement yet.
Spring controllers are not invoked when mixing between JSF 2 and JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring controllers are not invoked when mixing between JSF 2 and JSP

    my application contains some legacy jsp pages and the client doesn't want to convert them to xhtml, and i am trying to configure JSP pages to work in JSF 2 application, but i am getting problem that the controllers of the jsps are not getting invoked.

    web.xml:

    Code:
          <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
          </servlet>
          
          <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
          </servlet-mapping>
          
            <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.jsp</param-value>
            </context-param>
        
            
            <context-param>
                <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
                <param-value>*.xhtml</param-value>
            </context-param>
    applicationContext.xml:

    Code:
        <mvc:annotation-driven />
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        		<property name="prefix" value="/pages/jsps/"/>
        		<property name="suffix" value=".jsp"/>
        </bean>
    and my jsps are under: webapp/pages/jsps

    MyController:

    Code:
        @Controller
        @RequestMapping("/senddata")
        public class SendDataController {
        @RequestMapping(method = RequestMethod.GET)
            public String get(HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
                log.debug("SendDataController");
        
                return "senddata";
            }
        }
    ISSUE:

    i can only access the jsps via following link:

    Code:
     http://localhost:8080/MyApp/faces/pages/jsps/senddata.jsp
    and the controllers are not getting invoked, please advise how to make the controller gets invoked.

    and second question is how to make the url looks pretty as:

    Code:
    http://localhost:8080/MyApp/senddata
    i am using PrettyFaces for pretty urls for jsf, should i use tuckey url rewrite for the jsps ?

    when turning on the debug, i can see that the mapping is correct:

    Code:
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata] onto handler 'sendDataController'
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata] onto handler 'sendDataController'
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata.*] onto handler 'sendDataController'
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata.*] onto handler 'sendDataController'
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata/] onto handler 'sendDataController'
        2012-07-09/12:52:48.348 [Thread-2] INFO  Mapped URL path [/senddata/] onto handler 'sendDataController'

  • #2
    Hello

    If my memory doesnt fail me, Spring MVC has no support for JSF 2. Spring Web Flow yes for example.

    Comment

    Working...
    X