1
我開始將struts 2與瓷磚整合到IntelliJ環境中。Struts 2與Tiles問題集成
我在網上搜索了幾個教程,但我仍然看到一些奇怪的符號未找到問題。
這是在web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_2_5.xsd"
version="2.5">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
</web-app>
這是tiles.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="baseLayout" template="/baseLayout.jsp">
<put-attribute name="title" value="Template"/>
<put-attribute name="header" value="/header.jsp"/>
<put-attribute name="menu" value="/menu.jsp"/>
<put-attribute name="body" value="/body.jsp"/>
<put-attribute name="footer" value="/footer.jsp"/>
</definition>
<definition name="welcome" extends="baseLayout">
<put-attribute name="title" value="Welcome"/>
<put-attribute name="body" value="/welcome.jsp"/>
</definition>
<definition name="friends" extends="baseLayout">
<put-attribute name="title" value="Friends"/>
<put-attribute name="body" value="/friends.jsp"/>
</definition>
<definition name="office" extends="baseLayout">
<put-attribute name="title" value="Office"/>
<put-attribute name="body" value="/office.jsp"/>
</definition>
</tiles-definitions>
兩個瓷磚和WEB-INF目錄下的web.xml。
這是src目錄下的struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="FirstWebApp" extends="struts-default">
<result-types> <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/> </result-types>
<action name="*Link" method="{1}" class="hello.HelloWorld">
<result type="tiles" name="welcome">welcome</result>
<result type="tiles" name="friends">friends</result>
<result type="tiles" name="office">office</result>
</action>
</package>
</struts>
我得到四個錯誤,我認爲他們在下面兩個不同的羣體:
- 錯誤:(12,13)無法解析符號「歡迎」
- 錯誤:(13,13)無法解析符號「朋友」
- 錯誤:(8,42)無法解析包「支柱默認」
- 錯誤:(14,13)無法解析符號「辦公室」
對於錯誤3,如果我從互聯網上新增的struts-default.xml中,我看到一羣其他類未發現相關的COM錯誤。 opensymphony.xwork2包。
對於錯誤1,2和4,我不知道如何讓struts.xml查看tiles.xml來解決符號問題。
在此先感謝您的幫助。
你有沒有發現什麼原因呢? – Lrrr 2015-04-11 11:05:59