【发布时间】:2011-01-12 18:03:16
【问题描述】:
我对 Java 还很陌生,只是遇到了一个奇怪的问题。以前,一切正常,我不知道我做了什么把它搞砸了(我知道,每个人都这么说)。发生的事情是,我正在开发一个使用 Apache Struts (1.x) 和 Tiles 的 Web 应用程序,当我在 Web 浏览器中转到一个页面时,它似乎使用了与以前不同的 Tile 定义。
这是来自 tiles-config.xml 的相关行:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration//EN"
"http://supplies.ur.com/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name=".default" path="/template_new.jsp">
<put name="title" value="[Company Web App Name]" direct="true"/>
<put name="customerInfo" value="/customerInfo.jsp" direct="false"/>
<put name="smallBody" value="" direct="true"/>
<put name="menu" value="" direct="true"/>
<put name="quickMenu" value="/quickMenu.jsp" direct="false"/>
<put name="adminMenu" value="/adminMenu.jsp" direct="false"/>
<put name="message" value="/message.jsp" direct="false"/>
<put name="body" value="" direct="true"/>
<put name="helpAvailable" value="yes" direct="false"/>
<put name="feedbackAvailable" value="yes" direct="false"/>
<put name="problemReportingAvailable" value="yes" direct="false"/>
<put name="newFeaturesAvailable" value="yes" direct="false"/>
</definition>
<definition name=".empty" path="/blank.jsp">
<put name="title" value="[Company Web App Name]" direct="true"/>
<put name="customerInfo" value="/customerInfo.jsp" direct="false"/>
<put name="quickMenu" value="/quickMenu.jsp" direct="false"/>
<put name="message" value="/message.jsp" direct="false"/>
<put name="body" value="" direct="true"/>
<put name="footer" value="/footer2.jsp" direct="false"/>
<put name="helpAvailable" value="yes" direct="false"/>
<put name="feedbackAvailable" value="yes" direct="false"/>
<put name="problemReportingAvailable" value="yes" direct="false"/>
<put name="newFeaturesAvailable" value="yes" direct="false"/>
</definition>
<!-- Forgot to include the .rentalHistoryByType definition... -->
<definition name=".rentalHistoryByType" extends=".default">
<put name="title" value="Equipment Rental History By Type" direct="true"/>
<put name="smallBody" value="/rentalHistoryByType_Search.jsp" direct="false"/>
<put name="body" value="/rentalHistoryByType.jsp" direct="false"/>
</definition>
<!-- Added for CoolBeans -->
<definition name=".customerChoose" extends=".default">
<put name="title" value="Choose a customer" direct="true"/>
<put name="quickMenu" value="" direct="true"/>
<put name="smallBody" value="/customerChoose_Search.jsp" direct="false"/>
<put name="body" value="/customerChoose.jsp" direct="false"/>
</definition>
</tiles-definitions>
以下是 struts-config.xml 中的相关行:
<action path="/rentalHistoryByType" type="com.[company name deleted].etrieveit.actions.RentalHistoryByTypeAction">
<forward name="customerNotSelected" path="/customerChoose.do" />
<forward name="success" path=".rentalHistoryByType" />
</action>
<!-- Added for CoolBeans -->
<action path="/customerChoose" type="com.[company name deleted].etrieveit.actions.CustomerChooseAction">
<forward name="success" path=".customerChoose" />
</action>
我要在浏览器中访问的页面是“[path]/rentalHistoryByType.do”,它的主体是用rentalHistoryByType_Search.jsp 和rentalHistoryByType.jsp 构建的。我发现问题的方式是 jQuery 突然停止在页面上工作,而它之前工作正常。在查看源代码时,我发现rentalHistoryByType.do 是从blank.jsp 构建的,而不是template_new.jsp。 (template_new.jsp 包含 jQuery 的脚本,而 blank.jsp 没有,页面源代码中的其他细节也完全匹配 blank.jsp。)
我的问题是,我如何知道页面在被请求时将使用哪个 Tile 定义以及如何更改它?和/或,什么可能导致页面使用与以前明显不同的 Tile 定义?
对不起,如果我的术语有误或令人困惑,我对 Java 还很陌生,我还不知道自己在做什么......
【问题讨论】:
-
你能粘贴struts-config.xml中定义了rentalHistoryByType动作的部分吗?
-
您能否也将 customerChoose.do 操作粘贴到您的 struts-config.xml 中?到目前为止,您粘贴的内容应该导致 template_new.jsp 不是空白。
-
我在上面的 struts-config 和 tiles-config 中添加了 customerChoose 部分。
-
嗯,奇怪的是,这两个都扩展了 .default,应该是 template_new.jsp。
-
我基本上被难住了。我之前遇到过一个问题(也在 Stack Overflow 上回答),NetBeans 出于某种原因将文件移动到另一个位置并且在编译时没有刷新它,但是对于这个我解压缩了复制到 JBoss 的 .war 文件并查看它们,其中的 struts-config 和 tiles-config 文件是正确的。我已经重新启动并清除了所有浏览器历史记录以确保缓存被清除,多次重新启动 JBoss 服务器等等。我不知道还有什么可做的。 :(
标签: java apache jsp struts tiles