在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