org.apache.tiles.definition.NoSuchDefinitionException
org.apache.tiles.definition.NoSuchDefinitionException
我尝试将图块添加到该项目中。但它一次又一次地给出同样的错误。
错误是
"org.apache.tiles.definition.NoSuchDefinitionException: /login-success"
这是我的文件夹结构。
这是我的 struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="tile_Framework" extends="tiles-default" >
<action name="login" class="tile_Framework.Login" method="execute">
<result name="success" type="tiles">/login-success</result>
<result name="error" type="tiles">/login-error</result>
</action>
</package>
</struts>
这是我的 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="login-success" template="/layoutmanager.jsp">
<put-attribute name="title" value="Welcome Page"/>
<put-attribute name="body" value="/login-success.jsp"/>
</definition>
<definition name="login-error" template="/layoutmanager.jsp">
<put-attribute name="title" value="Login Error"/>
<put-attribute name="body" value="/login-error.jsp"/>
</definition>
</tiles-definitions>
这里是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
这是我的 layoutmanager.jsp
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><tiles:getAsString name="title" /></title>
</head>
<body>
<%@ include file="header.jsp" %>
<tiles:insertAttribute name="body" />
<%@ include file="footer.jsp" %>
</body>
</html>
我怎么能从这个错误中恢复过来。
尝试更改:
<result name="success" type="tiles">/login-success</result>
至:
<result name="success" type="tiles">login-success</result>
我尝试将图块添加到该项目中。但它一次又一次地给出同样的错误。 错误是 "org.apache.tiles.definition.NoSuchDefinitionException: /login-success"
这是我的文件夹结构。
这是我的 struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="tile_Framework" extends="tiles-default" >
<action name="login" class="tile_Framework.Login" method="execute">
<result name="success" type="tiles">/login-success</result>
<result name="error" type="tiles">/login-error</result>
</action>
</package>
</struts>
这是我的 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="login-success" template="/layoutmanager.jsp">
<put-attribute name="title" value="Welcome Page"/>
<put-attribute name="body" value="/login-success.jsp"/>
</definition>
<definition name="login-error" template="/layoutmanager.jsp">
<put-attribute name="title" value="Login Error"/>
<put-attribute name="body" value="/login-error.jsp"/>
</definition>
</tiles-definitions>
这里是web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
这是我的 layoutmanager.jsp
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><tiles:getAsString name="title" /></title>
</head>
<body>
<%@ include file="header.jsp" %>
<tiles:insertAttribute name="body" />
<%@ include file="footer.jsp" %>
</body>
</html>
我怎么能从这个错误中恢复过来。
尝试更改:
<result name="success" type="tiles">/login-success</result>
至:
<result name="success" type="tiles">login-success</result>