gpt4 book ai didi

struts2 - Apache Tiles 问题 - org.apache.tiles.jsp.taglib.InsertAttributeTag 无法转换为 javax.servlet.jsp.tagext.Tag

转载 作者:行者123 更新时间:2023-12-04 23:23:30 29 4
gpt4 key购买 nike

我尝试在 Struts 2 中使用 tile 2.2.2。我在项目中包含了所有必要的 jars(与 tile、Struts2 和 Struts2 tile 插件相关)。

commons-beanutils-1.8.0.jar
commons-collections-3.1.jar
commons-digester-2.0.jar
commons-fileupload-1.3.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
slf4j-api-1.5.8.jar
slf4j-jdk14-1.5.8.jar
struts2-core-2.3.15.jar
struts2-tiles-plugin-2.3.15.jar
tiles-api-2.2.2.jar
tiles-compat-2.2.2.jar
tiles-core-2.2.2.jar
tiles-jsp-2.2.2.jar
tiles-servlet-2.2.2.jar
tiles-template-2.2.2.jar
xwork-core-2.3.15.jar

瓷砖.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="" />
<put-attribute name="header" value="/Header.jsp" />
<put-attribute name="menu" value="/Menu.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/Footer.jsp" />
</definition>

<definition name="/welcome.tiles" extends="baseLayout">
<put-attribute name="title" value="Welcome" />
<put-attribute name="body" value="/Welcome.jsp" />
</definition>

<definition name="/employee.tiles" extends="baseLayout">
<put-attribute name="title" value="Employee Form" />
<put-attribute name="body" value="/Employee.jsp" />
</definition>
<definition name="/employee.success.tiles" extends="baseLayout">
<put-attribute name="title" value="Employee Added" />
<put-attribute name="body" value="/SuccessEmployee.jsp" />
</definition>

</tiles-definitions>

网页.xml

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_9" version="2.4">
<javaee:display-name>Apache Tiles framework</javaee:display-name>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<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>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
</web-app>

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>
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />

<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<action name="login"
class="com.teg.tiles.LoginAction">
<result name="success" type="tiles">/welcome.tiles</result>
<result name="error">Login.jsp</result>
</action>
<action name="employee"
class="com.teg.tiles.EmployeeAction">
<result name="success" type="tiles">/employee.success.tiles</result>
<result name="input" type="tiles">/employee.tiles</result>
</action>
<action name="employee-form">
<result name="success" type="tiles">/employee.tiles</result>
</action>
</package>
</struts>

当我尝试运行该项目时,出现以下异常。

java.lang.ClassCastException: org.apache.tiles.jsp.taglib.InsertAttributeTag cannot be cast to javax.servlet.jsp.tagext.Tag



请帮我解决问题。

最佳答案

我面临着完全相同的问题,在我的案例中的问题是 JSP 没有重新编译并且 Tomcat 在 work 中重新使用相同的副本。目录。清洁 work目录并重新部署为我解决了这个问题。希望能帮助到你!

关于struts2 - Apache Tiles 问题 - org.apache.tiles.jsp.taglib.InsertAttributeTag 无法转换为 javax.servlet.jsp.tagext.Tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17904917/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com