开发者

JSP can't find stylesheets, images [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

JSP can't find stylesheet

Tomcat7, spring framework3, jstl 1.2. Hierarchy: WEB-INF/jsp WEB-INF/styles

I link stylesheet in my JSP file, which is located in WEB-INF/jsp: But it doesn't work! When i open my application there is no styles, and writter by Tomcat:

Apache Tomcat/7.0.14 - Error report
HTTP Status 404 -

type Status report

message

description The requested resource () is not available.
Apache Tomcat/7.0.14

So i put my styles folder out of WEB-INF and it still doesn't work! Al开发者_开发技巧so, images too don't work, but my images folder not in WEB-INF and their path is corect... What is the problem?


In Spring I put my resources in a folder outside of web-inf. Like this:

JSP can't find stylesheets, images [duplicate]

Web.xml

<!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

Then in my servlet-context.xml (configuration file specified in web.xml) file I exclude the resources directory from being managed by the dispatcher, so URLs prefixed with resources/ are not picked up by the dispatcher and attempted to be routed to an appropriate controller.

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

In my jsp I can then access resources as normal:

<link rel="stylesheet" type="text/css" href="/skillsmanager-ui/resources/css/reset.css" /> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜