Results 1 to 2 of 2

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

  1. #1
    Join Date
    Oct 2011
    Posts
    18

    Default 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. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

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

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •