Announcement Announcement Module
Collapse
No announcement yet.
resolving jsp and html files with the same project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • resolving jsp and html files with the same project

    I have a spring project.

    I have my jsp files under /WEB-INF/jsp/

    I have some html files i need to serve as well under /WEB-INF/console/

    I am using SimpleUrlHandlerMapping for mappings defined as shown below.

    Code:
        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	      <property name="mappings">
                <value>
                    /**/hello.htm=helloController
                    /**/login.htm=loginController
                    /**/messagebroker/amf=mySpringManagedMessageBroker
                    /**/snas_admin.html=snasAdminConsoleController
                </value>
          </property>
          <property name="alwaysUseFullPath" value="true"/>
        </bean>

    I have defined a View Controller and a View Resolver as shown.
    Code:
    <bean id="urlFilenameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController">
      		<property name="prefix" value="/WEB-INF/console/"></property>
            <property name="suffix" value="*.html"></property>        
      	</bean>
    
    
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
            <property name="prefix" value="/WEB-INF/jsp/"></property>
            <property name="suffix" value="*.jsp"></property>        
        </bean>

    My resultant html url is as shown



    When The application tries to resolve to this url, I get the following error


    HTML Code:
    javax.servlet.ServletException: No adapter for handler [[email protected]04e]: Does your handler implement a supported interface like Controller?
    	org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1067)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:858)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    	com.ge.nbc.web.authentication.filter.SecurityFilter.doFilter(SecurityFilter.java:278)
    	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    In my web.xml i have defined my DispatcherServlet and mappings as shown


    Code:
    	<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    	<servlet>
    		<servlet-name>admin</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/admin-servlet.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
    	</servlet>
    
    
    	<servlet-mapping>
    		<servlet-name>admin</servlet-name>
    		<url-pattern>*.htm</url-pattern>
    	</servlet-mapping>
    	
    	<servlet-mapping>
    		<servlet-name>admin</servlet-name>
    		<url-pattern>/messagebroker/amf</url-pattern>
    	</servlet-mapping>
    	
    	<servlet-mapping>
    		<servlet-name>admin</servlet-name>
    		<url-pattern>*.html</url-pattern>
    	</servlet-mapping>
    What am I missing in order to correctly server both jsp and html pages in different locations?

    Thanks


    Myqyl4

  • #2
    Here is the resolution to the

    javax.servlet.ServletException: No adapter for handler [org.springframework.web.servlet.mvc.UrlFilenameVie wController@df804e]: Does your handler implement a supported interface like Controller

    Errors and such

    if you provide a custom HandlerAdapter you will lose the standard ones (which are listed in DispatcherServlet.properties). So the solution is to add the SimpleControllerHandlerAdapter to the application-servlet.xml,and everything should work again.


    e.g
    <bean id="controllerHandlerAdapter" class="org.springframework.web.servlet.mvc.SimpleC ontroll erHandlerAdapter"/>
    to my application-servlet-xml

    Everything works now!

    Comment

    Working...
    X