struts 2.3.16和瓷砖无法正常工作

时间:2014-05-11 15:48:40

标签: java xml struts2 tiles

我正在尝试使用struts 2.3.16和tiles 2.0.3构建我的应用程序。但是瓷砖没有按预期正常工作。每次我点击按钮都会产生错误:

INFO: Server startup in 3151 ms
java.lang.NullPointerException
May 11, 2014 8:55:51 PM org.apache.tiles.impl.BasicTilesContainer render
WARNING: Unable to find the definition 'validuser'

struts.xml中

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

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<constant name="struts.devMode" value="true" />
<package name="authenticate" extends="tiles-default">
    <action name="AuthenticateAction"
        class="in.ka.tutorialspoint.action.action.AuthenticationAction">
        <result name="success" type="tiles">validuser</result>
        <result name="failure" type="tiles">invaliduser</result>
    </action>
</package>
</struts>   

我的web.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/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>OnlineExamination</display-name>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- Dispatcher Description ends -->

<!-- Tiles Listener Registered for using tiles as plugin -->
<listener>
    <!-- <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class> -->
    <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
<!-- Tiles End -->


<!-- Struts Dispatcher Configuration for Applicaiton -->
<filter>
    <filter-name>strutsFilter</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>strutsFilter</filter-name>
    <url-pattern>*</url-pattern>
</filter-mapping>


</web-app>

和tiles.xml如下:

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

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<tiles-definition>
<definition name="base-layout" template="/Layout.jsp"
    abstract="true">
    <put-attribute name="header" value="/header.jsp" />
    <put-attribute name="footer" value="/footer.jsp" />
    <put-attribute name="menu" value="/menu.jsp"/>
</definition>

<definition name="validuser" extends="base-layout">
    <put-attribute name="title" value="Welcome Page"/>
    <put-attribute name="content-page" value="/result.jsp"/>
</definition>

<definition name="invaliduser" extends="base-layout">
    <put-attribute name="title" value="Login failed"/>
    <put-attribute name="content-page" value="/relogin.jsp"/>
</definition>

</tiles-definition>

0 个答案:

没有答案