Announcement Announcement Module
Collapse
No announcement yet.
Unable to add @Controller to SWF application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to add @Controller to SWF application

    Hi,

    I am trying to add a @Controller (for a simple CRUD page) to SWF application. Below is my webmvc-config.xml

    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:faces="http://www.springframework.org/schema/faces"
           xsi:schemaLocation="
           	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
           	http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd">
    	<faces:resources />
    	<!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
    	<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    		<property name="order" value="1"/>
    		<property name="flowRegistry" ref="flowRegistry" />
    		<property name="defaultHandler">
    			<!-- If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" -->	
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    		</property>
    	</bean>
    	<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
    	<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
    		<property name="prefix" value="/WEB-INF/" />
    		<property name="suffix" value=".xhtml" />
    	</bean>
    	<!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller implementations -->
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    	<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
    	<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor" />
    	</bean>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> <!-- @Controller -->
    </beans>
    This is web-application-config.xml:

    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd">
    	<!-- Scans for application @Components to deploy -->
    	<context:component-scan base-package="org.springframework.webflow.samples.booking" />
    	<bean name="richfacesResourceHandler" class="org.springframework.faces.webflow.JsfResourceRequestHandler" />
    	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	    <property name="order" value="0" />
    	    <property name="mappings">
    	        <value>
    	            /rfRes/**=richfacesResourceHandler
    	        </value>
    	    </property>
    	</bean>
    	<!-- Imports the configurations of the different infrastructure systems of the application -->
    	<import resource="webmvc-config.xml" />
    	<import resource="webflow-config.xml" />
    	<import resource="data-access-config.xml" />
    	<import resource="security-config.xml" />
    </beans>

    Below is my Controller class:
    Code:
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
    @Controller
    public class HelloController {
    	@RequestMapping(value = "/page/hello", method = RequestMethod.GET)
    	public ModelAndView printWelcome() {
    		System.out.println("\n\n\n*************called:");
            ModelAndView modelAndView = new ModelAndView("/page/hello.xhtml");//exists
            System.out.println("\n\n\n*************ModelAndView:"+modelAndView);//to debug
            //modelAndView.addObject("personalInfo", personalInfo);
            return modelAndView;
        }
    }
    It seems adding <bean class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter" /> to webmvc-config.xml alone doesnt suffice. When I try to navigate, I get a 404 error. No exceptions in any log/console. Could somebody help me out to resolve the problem ?

    Thanks for your time in advance.
    krishin
Working...
X