2017-09-13 55 views
0

我尝试添加瓷砖到这个项目。但它一次又一次地出现相同的错误。 错误是 “org.apache.tiles.definition.NoSuchDefinitionException:/ login-success”org.apache.tiles.definition.NoSuchDefinitionException

这是我的文件夹结构。

这里是我的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> 

我怎么能从这个错误来。

回答

1

尝试更改:

<result name="success" type="tiles">/login-success</result> 

到:

<result name="success" type="tiles">login-success</result> 
+0

谢谢you.it工作。 –

+0

如果问题解决了,您可以点击接受我的答案吗? –