English 中文(简体)
Spring MVC app中的法定资源
原标题:Static resources in Spring MVC app

在我春天的申请中,我想利用资源为静态资源服务。

我的网络xml绘图认为:

<servlet-mapping>
 <servlet-name>main</servlet-name>
 <url-pattern>/</url-pattern>       
</servlet-mapping>

主要为发送服务器,以提供所有内容

在我的“保护”档案中,我补充说:

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

当我的申请环境空洞时(如当地托管人:8080/),而且当我在其他情况下部署申请时,我就没有工作了404。

I tried many combinations:

"static/**"
"*/static/**"

任何东西都不可行。

我确信它是一个服务器问题,但我不知道(我也找不到谷歌的解决办法)如何解决这一问题。 请提供帮助。

问题回答

我得以利用以下公约精心规划我的固定资源:

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

我们工作最容易的方法是在servlet-config.xml上添加的。 The file that is configuated in web.xml as the contextConfigLocation) the following:

<mvc:default-servlet-handler/>




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签