-
Nov 11th, 2010, 09:44 PM
#1
mvc:recources and context:component-scan
hey ,
i am using ext-js for front end and spring mvc/> on server . later it was decided to put all static java script and css in jar files, so i upgraded, and added mvc:resources ,since then @Controller and @requesmapping stopped working, but resources were getting loaded as per mapping.
i had to add one more dispatcherservlet only for mvc:resources , well things are working but i have two servlets in web.xml,
so is there any way to avoid 2 servlets web.xml?
thanx
-
Nov 12th, 2010, 05:13 AM
#2
What does your servlet-mapping look like?
-
Nov 15th, 2010, 12:57 AM
#3
servlets in web.xml
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/hrm_core_beans.xml
/WEB-INF/config/admin-application-config.xml
</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/resources-application-config.xml
</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/admin/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
admin-application-config.xml
<context:component-scan base-package="org.sia.hrm.ui.web.controller" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlVi ew" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
resources-application-config.xml
<mvc:resources mapping="/**" location="classpath:/META-INF/resources/, /WEB-INF/resources/" cache-period="1000" />
if i put mvc:resources in admin-application-config.xml. mapping of my @Controller beans stop's working. this way it works fine
and yes if i am putting this mvc:resources in admin-application-config.xml i am changing the mapping as follows
<mvc:resources mapping="/resources/**" location="classpath:/META-INF/resources/, /WEB-INF/resources/" cache-period="1000" />
but still i doesnt works
and @controller beans are not using the same pattern anyways
@Controller
@RequestMapping(value="/client/*")
public class ClientController {
Last edited by fairoz.sharif; Nov 15th, 2010 at 01:00 AM.
-
Nov 19th, 2010, 05:23 PM
#4
I'm experiencing the same issue and your fix works fine, thanks fairoz.sharif.
This looks like a bug to me, I guess it should be filed.
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
-
Forum Rules