1

In my context file I want to add line to be able to access static content. Until I add it, everything works allright, but after I add it, I can't access pages that have some controller and I get this warning: WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/fit/] in DispatcherServlet with name 'mvc-dispatcher'. Before adding <mvc:resources mapping="/resources/**" location="/resources/" /> to context file, it looks like this:

<?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"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

<context:annotation-config />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory -->




<context:component-scan base-package="cz.cvut.fit.genepi.controllers" />
<import resource="classpath:applicationContext-security.xml" />
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

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

Any idea how to fix this?

PS:those pages are secured with Spring security, but I don't think that this could be the problem.

3
  • Please post your Web.xml and One Jsp and Controller also.I wana check how you have mapped incoming requests and how you are using static contents from your JSP page. Commented Sep 9, 2013 at 12:20
  • oh..this topic is not actuall in this moment, problem was solved. I'll post the answer with the code. Thanks for reminding :] Commented Sep 9, 2013 at 14:45
  • What was the solution? I don't find the answer you talk about :( Commented Jun 9, 2016 at 18:46

1 Answer 1

1

Every dispatcher servlet ends with -servlet. Try renaming your dispatcher servlet.

On initialization of a DispatcherServlet, the framework will look for a file named [servlet-name]-servlet.xml in the WEB-INF directory of your web application and create the beans defined there.

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

1 Comment

that would not be the problem. I've got explicitly defined in web.xml the path to dispatcher servlet <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> ...And as I've said - everything works well, until I add the line <mvc:resources mapping="/resources/**" location="/resources/" />

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.