操作未从Action中的前向路径转发到tiles-definition

时间:2012-08-24 11:07:55

标签: tiles struts-1

我的struts-config.xml有一些指向tile定义的前向动作。但它需要路径,因为它给予&没有指向tiles-definition.xml&显示路径不以"/"字符

开头

我的struts-config.xml是:

<?xml version="1.0" encoding="UTF-8"?>    

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
   <data-sources />
<form-beans >
   <form-bean name="feelSafeForm" type="com.feelsafe.struts.form.FeelSafeForm" />
</form-beans>
<global-exceptions />
<global-forwards >
   <forward name="login1" path="/feelSafe.do?do=login" />
   <forward name="admin" path="/feelSafe.do?do=admin1" />
</global-forwards>
<action-mappings >
<action
  attribute="feelSafeForm"
  input="/index.jsp"
  name="feelSafeForm"
  parameter="do"
  path="/feelSafe"
  scope="request"
  type="com.feelsafe1.struts.action.FeelSafeAction">

  <forward name="adminmainpage" path="feelsafe.adminmainpage" />
  <forward name="login" path="feelsafe.login" />

 </action>

</action-mappings>

<message-resources parameter="com.feelsafe.struts.ApplicationResources" />

<plug-in className="org.apache.struts.tiles.TilesPlugin">
   <set-property property="definitions-parser-validate" value="true" />
   <set-property property="moduleAware" value="true" />
   <set-property property="definitions-config" value="/WEB-INF/tiles-definition.xml" />
</plug-in>

</struts-config>

tiles-definition.xml是:

<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
   "http://struts.apache.org/dtds/tiles-config_1_1.dtd">     
<component-definitions>

<definition name="feelsafe.common" path="/feelsafeLayout/layout.jsp">
   <put name="title" type="string" value="FeelSafe Hospital"/>
   <put name="header1" value="/feelsafeLayout/header.jsp"/>
   <put name="footer1" value="/feelsafeLayout/footer.jsp"/>
</definition>

<definition name="feelsafe.login" extends="feelsafe.common">
   <put name="body1" value="/feelsafeJspFiles/login.jsp"/>
</definition> 

<definition name="feelsafe.admin" extends="feelsafe.common">
   <put name="body1" value="/feelsafeAdminJspFiles/adminlogin.jsp"/>
</definition>

</component-definitions>  

当调用login时,控制转到forward tag&amp;给500 Error说:

  

org.apache.jasper.JasperException:javax.servlet.ServletException:   javax.servlet.jsp.JspException:名称login1的异常转发:   javax.servlet.ServletException:java.lang.IllegalArgumentException:   路径feelafe.login不以“/”字符开头

1 个答案:

答案 0 :(得分:1)

当我从web.xml中的action servlet的init params中删除此代码段时,我得到了同样的错误

    ...
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    ...
    <init-param>
        <param-name>chainConfig</param-name>
        <param-value>org/apache/struts/tiles/chain-config.xml</param-value>
    </init-param>

因此,当您使用旧版本的dtd(如1.1)时,请尝试将此init-param添加到您的web.xml文件的操作servlet中。 我测试了1.3