1

先生,实际上我正在运行一个示例来开发用户详细信息页面。我目前正在使用附加到我的 Registration.jsp 页面的 Tiles.xml 进行此操作。

这是我的

瓷砖.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!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>

<!-- ************************************************************************************** -->
<!-- TEMPLATES***************************************************************************** -->
<!-- ************************************************************************************** -->
    <definition name="isas.mainLayout" template="/templates/MainLayout.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="" />
        <put-attribute name="pageHeading" value="" />
        <put-attribute name="nav" value="" />
        <put-attribute name="content" value="" />
        <put-attribute name="footer" value="" />
    </definition>

<!-- ERROR PAGES ********************************************************************** --> 
    <definition name="isas.errorPage" extends="isas.mainLayout">
        <put-attribute name="title" value="iSAS" />
        <put-attribute name="pageHeading" value="Error Page" />
        <put-attribute name="content" value="/errorPage.jsp" />
    </definition>

<!-- USER REGISTRATION PAGES ********************************************************************** --> 
    <definition name="isas.user.registration" extends="isas.mainLayout">
        <put-attribute name="title" value="User Registration" />
        <put-attribute name="pageHeading" value="User Registration" />
        <put-attribute name="content" value="/registration.jsp" />
    </definition>

</tiles-definitions>

web.xml

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<description>iSAS</description>

<filter>
    <filter-name>struts2</filter-name>
<!--<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> -->
       <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>

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

主布局.jsp

<%@ taglib uri="tiles-jsp.tld" prefix="tiles"%>
<%@ taglib uri="struts-tags.tld" prefix="struts"%>

<html>
<head>
  <meta HTTP-EQUIV="Content-Type" content="text/html"; charset=ISO-8859-1">
  <title>ISAS: <tiles:insertAttribute name="title"/></title>
  <style type="text/css">
  </style>
</head>
<body>
    <!-- Header -->
    <!-- <tiles:insertAttribute name="header" ignore="true"/>

    <!-- Page Header -->
  <div class="noprint">
    <table>
      <tr valign="top">
        <td width=10px></td>
        <td vAlign=top width="99%">         

                <div>
                     <span><tiles:insertAttribute name="pageHeading"/></span>
                </div>
         </td>
       </tr>
    </table>
</div>  
    <!-- Navigation -->
 <div>
    <table>
    <tr>
    <td vAlign=top align="center" width="100%"> 
    <tiles:insertAttribute name="nav" ignore="true"/>
    </td>
    </tr>
    </table>    
</div>
    <!-- Body Content -->
<table>
     <tbody>
      <tr>              
        <td width=10px></td>
        <td vAlign=top align="center" width="99%">  
            <tiles:insertAttribute name="content" ignore="true"/>
        </td>
      </tr>
     </tbody>
    </table>
    <table>
     <tbody>
      <tr>
        <td vAlign=top align="center" width="99%">  
            <br>
        </td>
      </tr>
     </tbody>
    </table>
    <!-- Footer -->
<tiles:insertAttribute name="footer" ignore="true"/>

</body>

注册.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>registration</title>
</head>
<body bgcolor="pink">
<s:form action="userRegistration">
    <s:label label="Register to Login"></s:label>
    <s:textfield name="first_Name" label="First Name"/>
    <s:textfield name="last_Name" label="Last Name"/>
    <s:textfield name="emailid" label="Email ID"/>
    <s:textfield name="passWord" label="Password"/>
    <s:textfield name="Gender" label="Gender"/>
    <s:textfield name="dateofbirth" label="DOB"/>
    <s:textfield name="phoneNo" label="Mobile No."/>
    <s:textfield name="user_experience" label="Experience"/>
    <s:textfield name="addr_line1" label="Address Line 1"/>
    <s:textfield name="addr_line2" label="Address Line 2"/>
    <s:textfield name="addr_line3" label="Address Line 3"/>
    <s:textfield name="city" label="City"/>
    <s:textfield name="zipcode" label="Zipcode"/>
    <s:textfield name="state" label="State"/>
    <s:textfield name="country" label="Country"/>
    <s:submit/>
</s:form>
</body>
</html>

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.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.devMode" value="true" />

    <package name="default" extends="struts-default">       
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>

    <action name="userRegistration_*" method="{1}" class="userRegistration">
            <result name="SUCCESS" type="tiles">isas.user.registration</result>
            <result name="ERROR" type="tiles">isas.errorPage</result>
            <result name="input" type="tiles">isas.user.registration</result>
        </action> 
    </package>
</struts>

实际上,我无法查看我在 regisration.jsp 文件中使用的标签。

4

0 回答 0