如何确定 JSP 页面使用哪个 Tile 定义?
我对 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 还很陌生,我还不知道我在做什么......
I'm pretty new to Java, and just encountered a strange problem. Previously, everything was working fine and I don't know what I did to screw it up (I know, everyone says that). What's happening is that I am working on a web app that uses Apache Struts (1.x) and Tiles, and when I go to a page in the web browser, it seems to be using a different Tile definition than it used to.
Here's the relevant lines from 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>
Here's the relevant lines from 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>
The page I'm going to in the browser is "[path]/rentalHistoryByType.do", the body of which is built with rentalHistoryByType_Search.jsp and rentalHistoryByType.jsp. The way I found the problem is that jQuery suddenly stopped working on the page when it had been working fine before. On viewing source, I found that rentalHistoryByType.do is being built from blank.jsp, not template_new.jsp. (template_new.jsp has the script includes for jQuery, whereas blank.jsp does not, and other details in the page source match blank.jsp exactly as well.)
My question is, how can I tell which Tile definition a page is going to use when it gets requested and how can I change it? And/or, what might cause a page to use a different Tile definition than it was apparently using before?
Sorry if my terminology is wrong or confusing, I'm new enough to Java that I don't really know what I'm doing yet...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应该有一个 struts 配置文件(通常名为 struts-config.xml),其中包含操作到定义的映射,例如,它将包含
There should be a struts config file (named struts-config.xml typically) that has a mapping of actions to definitions, e.g. it would contain
找到了答案;这显然是一个缓存问题。我停止了 JBoss,删除了 JBoss 的 \server\default\tmp 和 \server\default\work 文件夹中的内容,然后重新启动了 JBoss,现在它可以正常工作了...
Found the answer; it was apparently a caching issue. I stopped JBoss, deleted the contents of JBoss's \server\default\tmp and \server\default\work folders, and restarted JBoss, and now it's working correctly...