Evgeni Dimitrov
Evgeni Dimitrov

Reputation: 22506

Spring-MVC doesn't work when add mvc namespace

My MVC project works perfectly without the mvc namespace, but when add it...

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        ">

    <context:component-scan base-package="com.evgeni.msgdisp.controller" />

    <mvc:resources mapping="/resources/**" location="/resources/" /> 

    <bean id="templateResolver"
        class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
        <property name="prefix" value="/WEB-INF/pages/" />
        <property name="suffix" value=".html" />
        <property name="templateMode" value="HTML5" />
        <property name="cacheable" value="false" />
    </bean>

    <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver" />
    </bean>

    <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
        <property name="templateEngine" ref="templateEngine" />
        <property name="characterEncoding" value="UTF-8" />
    </bean>

</beans>

I get 404 and the log says No handler mapping found for [/node/manage]. It's the same for jsp, so not Thimeleaf problem. I'm pretty sure it's something with the xsd version. I use Spring 3.2.

Upvotes: 1

Views: 7332

Answers (2)

Thanks by your comments about 'annotations'.

Be carefull using annotation-driven, two days ago my project doesn't work with resources directory, because i was mixing spring 3.2.8 with hibernate 4.2.6. They use his own annotations sets. Mixing both technologies, in servlet configuration is ussefull use two annotations tags:

<mvc:annotation-driven/> in controller and views configuration
<mvc:resources mapping=" ...
...

<tx:annotation-driven/> in transacional or hibernate configuration

Resources mapping only works with this tags combination, for differents anotation technologies.

Bye.

Upvotes: 0

Evgeni Dimitrov
Evgeni Dimitrov

Reputation: 22506

Solved by adding

<mvc:annotation-driven/> 

apparently the default behavior is overriden when use

<mvc:resources mapping="/resources/**" location="/resources/" /> 

Upvotes: 2

Related Questions