1

I m developing a spring web application . I have put all my resources folder in webcontent folder and configured it in my dispatcher.xml

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

I have configured my startup page as following

<mvc:view-controller path="/" view-name="Framework/start"/>

My application is running fine and all the resources are also loading but not on the first run. Means when I deploy my application on tomcat7 and hit the url for the first time the css are not loaded also my href which is mapped to a controller is also not working but once I am logged in and logout everything works fine.

0

1 Answer 1

3

After lots of effort i concluded that the problem was not with the resource path but the problem was due to the interceptor . The authentication interceptor that i have added was called multiple times due to the request to the resources and as there was no session created till that time it was returning false. Hence i exclude any calls to resources folder from the interceptor in the following way-

<mvc:interceptors>
        <mvc:interceptor>
                <mvc:mapping path="/**"/>
                <mvc:exclude-mapping path="/asset/**"/>         
            <bean class="com.model.AuthenticationInterceptor" />
        </mvc:interceptor>
</mvc:interceptors>

Also one imp thing mvc:exclude-mapping is added from spring 3.2 onwards so one need add the schema "http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.