2

I'm trying to make my application works with WebJars running on Tomcat7 but the CSS/JS files aren't found by my HTML pages.

I already change the web.xml to v3.0 and the facets of the project too (inside Eclipse). Also checked the web.xml from tge container and that's already configured as v3.0 too.

As I'm using SpringMVC, I made the configuration described into the official documentation:

<resources mapping="/webjars/**"    location="classpath:/META-INF/resources/webjars/"/>

Inside my "sitemesh3.xml" file, I already configured an exclusion to the folder "resources":

<?xml version="1.0" encoding="UTF-8"?>

<sitemesh>
    <mapping path="/*" decorator="/resources/decorator.html"/>
    <mapping path="/resources/*" exclue="true"/>

    <content-processor>
        <tag-rule-bundle class="org.sitemesh.content.tagrules.html.DivExtractingTagRuleBundle" />
    </content-processor>
</sitemesh>

Inside my "decotator.html" file I'm trying to access the JS by this way:

<script src="/webjars/select2/select2.js"></script>

or

<script src="../webjars/select2/select2.js"></script>

Inside my "pom.xml" file correctly added the dependency:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>select2</artifactId>
    <version>3.4.5</version>
</dependency>

To me it looks like the Tomcat7 is deploying the application as servlet version 2.5, once that the files inside the select2.jar aren't being public exposed.

Does someone know if I need to configure something more? Can you see anything wrong?

4

1 回答 1

2

两种可能的想法:

有一个错字:

<mapping path="/resources/*" exclue="true"/>

应该exclude不是exclue

也许你的sitemesh3.xml排除是:

<mapping path="/webjars/*" exclude="true"/>
于 2014-05-06T17:34:54.563 回答