在Struts2应用程序中,任何其他来源(图像,CSS,JavaScript文件)都不能被检索到浏览器。没有任何来源加载到浏览器的struts2中
例如,我在JSP页面中添加了<img src="myimage.jpg" />
,但图像未在浏览器中查看。 JSP页面和图像存在于web
文件夹中,而不是WEB-INF
我确定该图像存在于给定路径中(我使用Netbeans IDE并自动提供路径),我在相关位置手动检查了图像,没关系。我不确定这是否是Struts问题(我不这么认为),但我创建了另一个普通的Java EE项目,它只包含JSP页面,没有包含struts框架,然后一切正常(图像,CSS ,js打电话)。请任何人告诉我我的错在哪里?提前致谢。
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/org.apache.struts2.dispatcher.FilterDispatcher</welcome-file>
</welcome-file-list>
<jsp-config>
<jsp-property-group>
<url-pattern>/account.jsp</url-pattern>
<include-prelude>/header/header.jsp</include-prelude>
</jsp-property-group>
<jsp-property-group>
<display-name>TopBanner</display-name>
<url-pattern>/*</url-pattern>
<include-prelude>/header.jsp</include-prelude>
</jsp-property-group>
</jsp-config>
<servlet-name>ItemAction</servlet-name>
<url-pattern>/ItemAction</url-pattern>
</servlet-mapping-->
</web-app>
这是不是足够的信息来帮助;我们对你的应用程序的配置,部署等一无所知。你说得对,它不是一个Struts问题。 – 2012-07-06 13:26:34
@DaveNewton,谢谢,我在NetBeans IDE中创建了更多带有struts2框架的应用程序。他们工作得很好(但第一次,他们也失败了,我一次又一次地重建,然后他们跑得很好)。我仍然不明白问题是否存在。我把web.xml。 – 2012-07-06 16:28:37