Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法理解为什么在准备后未调用register方法。始终调用customeraction-validation.xml_Java_Xml_Jsp_Struts2_Tiles - Fatal编程技术网

Java 无法理解为什么在准备后未调用register方法。始终调用customeraction-validation.xml

Java 无法理解为什么在准备后未调用register方法。始终调用customeraction-validation.xml,java,xml,jsp,struts2,tiles,Java,Xml,Jsp,Struts2,Tiles,我正在struts2中开发一个示例web应用程序。但是我有一些奇怪的行为 CustomerAction.java: package com.astro.action; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import javax.servlet.http.*; import jav

我正在struts2中开发一个示例web应用程序。但是我有一些奇怪的行为

CustomerAction.java:

package com.astro.action;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.*;
import javax.servlet.*;
import com.astro.model.*;

import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.interceptor.validation.SkipValidation;

//import org.hibernate.classic.Validatable;

import com.astro.base.framework.AstroSystemException;
import com.astro.bo.CustomerBo;
import com.astro.model.Customer;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;

public class CustomerAction extends ActionSupport implements  Serializable,SessionAware,Preparable, ModelDriven<CustomerPageInfo>{
    private static final long serialVersionUID = 2335707118972931221L;

    private Map<String,Object> session;
    String target = "";
    //DI via Spring

    private CustomerPageInfo model;
    private CustomerBo customerBo;
    private Customer customer=new Customer();
    public CustomerBo getCustomerBo() {
        return customerBo;
    }
    public void setCustomerBo(CustomerBo customerBo) {
        this.customerBo = customerBo;
    }

    public String errorDisplay()
    {
        return "input";
    }
    //Register a Customer
            public String register() throws Exception{
                System.out.println("I am in register method of CustomerAction.java");
                System.out.println("((())))"+model.getCountryList().toString());
                System.out.println("((())))"+model.getCustomerInfo());
                model.getCustomerInfo().setCreatedDate(new Date());
                 customerBo.register(customer);
                return SUCCESS;
                }

    public void prepare() throws Exception {
        if(model==null)
        {
            model=new CustomerPageInfo();
            System.out.println("In prepare method");
            if(model.getCountryList()==null)
            {
                List<NameValuePair> countryList=customerBo.getAllCountries();
                model.setCountryList(countryList);
            }
            System.out.println("Before initializing"+model.getCustomerInfo());
            if(model.getCustomerInfo()==null)
            {
                model.setCustomerInfo(customer);
            }
            System.out.println("After initializing"+model.getCustomerInfo());
        }

    }

    @Override
    public void setSession(Map<String, Object> map) {
        this.session=map;
    }

    /*public void validate()
    {
        try {
            if(customerBo.doesCustomerExists(customer)==true)
            {
                addActionError("Customer Alreay Exists");
            }
            else
            {
                addActionMessage(INPUT);
            }
        } catch (AstroSystemException e) {
            e.printStackTrace();
        }

    }
*/
    public void setModel(CustomerPageInfo model)
    {

    this.model=model;
    }

    public CustomerPageInfo getModel()
    {
        return model;
    }
}
<?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.devMode" value="true" />
    <constant name="struts.configuration.xml.reload" value="true" />
    <constant name="struts.action.extension" value="do" />
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.custom.i18n.resources" value="ApplicationResources" />
    <!-- <constant name="struts.freemarker.mru.max.strong.size" value="250" /> -->
    <constant name="struts.freemarker.templatesCache.updateDelay"
        value="60000" />
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />

    <package name="astro" extends="struts-default" namespace="/">

        <!-- Different types of result types -->
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>

        <interceptors>
                <interceptor-stack name="defaultStack">
                <interceptor-ref name="exception"/>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="servletConfig"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="debugging"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="checkbox"/>
                <interceptor-ref name="multiselect"/>
                <interceptor-ref name="actionMappingParams"/>
                <interceptor-ref name="params">
                  <param name="excludeParams">dojo\..*,^struts\..*</param>
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="validation">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
            </interceptor-stack>

        </interceptors>
         <action name="registerCustomer" class="customerAction" method="register"> 
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="redirectAction">
                <param name="actionName">successInformation</param>
            </result>
            <result name="input" type="tiles">/registration.tiles</result>
        </action>

        <action name="successInformation" class="com.astro.action.DisplayAction"
            method="display">
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="tiles">/regSuccess.tiles</result>
        </action>

        <action name="loginCustomer" class="loginAction" method="login">
            <result name="success" type="tiles">/loginSuccess.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="loginCustomer1" class="loginAction" method="logout">
            <result name="success" type="tiles">/loginForm.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="login" class="com.astro.action.DisplayAction1"
            method="display">
            <result name="success" type="tiles">/loginForm.tiles</result>
        </action>
        <action name="feedback" class="com.astro.action.DisplayAction1"
            method="display1">
            <result name="success" type="tiles">/contact.tiles</result>
            <result name="input" type="tiles">/contact.tiles</result>
        </action>
        <action name="contactus" class="contactAction" method="contact">
            <result name="success" type="tiles">/contactus.tiles</result>
            <result name="input" type="tiles">/contactsuccess.tiles
            </result>
        </action>
    </package>

</struts>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page session="false"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<style type="text/css">
@import url(css/main.css);
</style>
<style>
.errorMessage {
    color: red;
}
.errors {
    background-color:#FFCCCC;
    border:1px solid #CC0000;
    width:400px;
    margin-bottom:8px;
    font: message-box;
}
.errors li{ 
    list-style: none; 
    }
</style>
<style type="text/css">
.errorsBg{
    background-color:;
    color:black;    
    border: 0px solid;
}

.errorMessage{
    padding:4px 8px;
}

 table{
    border-spacing: 8px;
} 
td{
    padding:5px;
}
</style>
<script>
/* $(document).ready(function(){
  $("input").keydown(function(){
    $("input").css("background-color","yellow");
  });
  $("input").keyup(function(){
    $("input").css("background-color","pink");
  });
}); */
</script>
</head>

<html>
<head>
</head>
<body bgcolor="green">
    <!-- <h1>Welcome to Astro vedic</h1>
    <h2>Register a Customer</h2> -->
    <div class="errors" style="width: 500px">
    <s:token></s:token>
    </div>
<s:if test="hasActionErrors()">
   <div class="errors">
      <s:actionerror/>
   </div>
</s:if>
<s:form action="registerCustomer.do" focusElement="focus" method="post" validate="true" namespace="/">
<s:actionerror /> 
            <s:textfield id="focus" name="name" key="name" size="20" />
            <s:password name="password" label="Password "/>
            <s:password name="confirmPassword" label="Re-enter Password "/>
            <s:textfield name="email" key="email" size="20" required="true" />
             <s:textfield name="telephone" key="telephone" size="20"></s:textfield> 
            <s:select required="true" name="countryCode" label="CountryName" listValue="name" headerKey="" headerValue="Choose One"
            list="countryList" listKey="value"/>  
            <s:submit align="center" key="addCustomer"/>

        </s:form>
    </div>
</body>
</html>
package com.astro.action;
导入java.io.Serializable;
导入java.util.ArrayList;
导入java.util.Date;
导入java.util.List;
导入java.util.Map;
导入javax.servlet.http.*;
导入javax.servlet.*;
导入com.astro.model.*;
导入org.apache.struts2.interceptor.SessionAware;
导入org.apache.struts2.interceptor.validation.SkipValidation;
//导入org.hibernate.classic.validable;
导入com.astro.base.framework.AstroSystemException;
导入com.astro.bo.CustomerBo;
导入com.astro.model.Customer;
导入com.opensymphony.xwork2.ActionContext;
导入com.opensymphony.xwork2.ActionSupport;
导入com.opensymphony.xwork2.ModelDriven;
导入com.opensymphony.xwork2.Preparable;
导入com.opensymphony.xwork2.validatable;
公共类CustomerAction扩展ActionSupport实现可序列化、SessionAware、可准备、模型驱动{
私有静态最终长serialVersionUID=23357071189729312L;
私人Map会议;
字符串target=“”;
//通过弹簧
私有客户页面信息模型;
私人顾客;
私人客户=新客户();
公共CustomerBo getCustomerBo(){
返回客户bo;
}
公共无效设置CustomerBo(CustomerBo CustomerBo){
this.customerBo=customerBo;
}
公共字符串errorDisplay()
{
返回“输入”;
}
//登记客户
公共字符串寄存器()引发异常{
System.out.println(“我在CustomerAction.java的register方法中”);
System.out.println((())“+model.getCountryList().toString());
System.out.println((())“+model.getCustomerInfo());
model.getCustomerInfo().setCreatedDate(新日期());
客户登记簿(客户);
回归成功;
}
public void prepare()引发异常{
if(model==null)
{
模型=新CustomerPageInfo();
System.out.println(“准备中方法”);
if(model.getCountryList()==null)
{
List countryList=customerBo.getAllCountries();
model.setCountryList(countryList);
}
System.out.println(“初始化前”+model.getCustomerInfo());
if(model.getCustomerInfo()==null)
{
model.setCustomerInfo(客户);
}
System.out.println(“初始化后”+model.getCustomerInfo());
}
}
@凌驾
公共无效设置会话(映射){
session=map;
}
/*public void validate()
{
试一试{
if(customerBo.doesCustomerExists(customer)=true)
{
addActionError(“客户始终存在”);
}
其他的
{
addActionMessage(输入);
}
}捕获(AstroSysteme例外){
e、 printStackTrace();
}
}
*/
公共void集合模型(CustomerPageInfo模型)
{
这个模型=模型;
}
公共CustomerPageInfo getModel()
{
收益模型;
}
}
struts.xml:

package com.astro.action;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.*;
import javax.servlet.*;
import com.astro.model.*;

import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.interceptor.validation.SkipValidation;

//import org.hibernate.classic.Validatable;

import com.astro.base.framework.AstroSystemException;
import com.astro.bo.CustomerBo;
import com.astro.model.Customer;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;

public class CustomerAction extends ActionSupport implements  Serializable,SessionAware,Preparable, ModelDriven<CustomerPageInfo>{
    private static final long serialVersionUID = 2335707118972931221L;

    private Map<String,Object> session;
    String target = "";
    //DI via Spring

    private CustomerPageInfo model;
    private CustomerBo customerBo;
    private Customer customer=new Customer();
    public CustomerBo getCustomerBo() {
        return customerBo;
    }
    public void setCustomerBo(CustomerBo customerBo) {
        this.customerBo = customerBo;
    }

    public String errorDisplay()
    {
        return "input";
    }
    //Register a Customer
            public String register() throws Exception{
                System.out.println("I am in register method of CustomerAction.java");
                System.out.println("((())))"+model.getCountryList().toString());
                System.out.println("((())))"+model.getCustomerInfo());
                model.getCustomerInfo().setCreatedDate(new Date());
                 customerBo.register(customer);
                return SUCCESS;
                }

    public void prepare() throws Exception {
        if(model==null)
        {
            model=new CustomerPageInfo();
            System.out.println("In prepare method");
            if(model.getCountryList()==null)
            {
                List<NameValuePair> countryList=customerBo.getAllCountries();
                model.setCountryList(countryList);
            }
            System.out.println("Before initializing"+model.getCustomerInfo());
            if(model.getCustomerInfo()==null)
            {
                model.setCustomerInfo(customer);
            }
            System.out.println("After initializing"+model.getCustomerInfo());
        }

    }

    @Override
    public void setSession(Map<String, Object> map) {
        this.session=map;
    }

    /*public void validate()
    {
        try {
            if(customerBo.doesCustomerExists(customer)==true)
            {
                addActionError("Customer Alreay Exists");
            }
            else
            {
                addActionMessage(INPUT);
            }
        } catch (AstroSystemException e) {
            e.printStackTrace();
        }

    }
*/
    public void setModel(CustomerPageInfo model)
    {

    this.model=model;
    }

    public CustomerPageInfo getModel()
    {
        return model;
    }
}
<?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.devMode" value="true" />
    <constant name="struts.configuration.xml.reload" value="true" />
    <constant name="struts.action.extension" value="do" />
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.custom.i18n.resources" value="ApplicationResources" />
    <!-- <constant name="struts.freemarker.mru.max.strong.size" value="250" /> -->
    <constant name="struts.freemarker.templatesCache.updateDelay"
        value="60000" />
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />

    <package name="astro" extends="struts-default" namespace="/">

        <!-- Different types of result types -->
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>

        <interceptors>
                <interceptor-stack name="defaultStack">
                <interceptor-ref name="exception"/>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="servletConfig"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="debugging"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="checkbox"/>
                <interceptor-ref name="multiselect"/>
                <interceptor-ref name="actionMappingParams"/>
                <interceptor-ref name="params">
                  <param name="excludeParams">dojo\..*,^struts\..*</param>
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="validation">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
            </interceptor-stack>

        </interceptors>
         <action name="registerCustomer" class="customerAction" method="register"> 
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="redirectAction">
                <param name="actionName">successInformation</param>
            </result>
            <result name="input" type="tiles">/registration.tiles</result>
        </action>

        <action name="successInformation" class="com.astro.action.DisplayAction"
            method="display">
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="tiles">/regSuccess.tiles</result>
        </action>

        <action name="loginCustomer" class="loginAction" method="login">
            <result name="success" type="tiles">/loginSuccess.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="loginCustomer1" class="loginAction" method="logout">
            <result name="success" type="tiles">/loginForm.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="login" class="com.astro.action.DisplayAction1"
            method="display">
            <result name="success" type="tiles">/loginForm.tiles</result>
        </action>
        <action name="feedback" class="com.astro.action.DisplayAction1"
            method="display1">
            <result name="success" type="tiles">/contact.tiles</result>
            <result name="input" type="tiles">/contact.tiles</result>
        </action>
        <action name="contactus" class="contactAction" method="contact">
            <result name="success" type="tiles">/contactus.tiles</result>
            <result name="input" type="tiles">/contactsuccess.tiles
            </result>
        </action>
    </package>

</struts>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page session="false"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<style type="text/css">
@import url(css/main.css);
</style>
<style>
.errorMessage {
    color: red;
}
.errors {
    background-color:#FFCCCC;
    border:1px solid #CC0000;
    width:400px;
    margin-bottom:8px;
    font: message-box;
}
.errors li{ 
    list-style: none; 
    }
</style>
<style type="text/css">
.errorsBg{
    background-color:;
    color:black;    
    border: 0px solid;
}

.errorMessage{
    padding:4px 8px;
}

 table{
    border-spacing: 8px;
} 
td{
    padding:5px;
}
</style>
<script>
/* $(document).ready(function(){
  $("input").keydown(function(){
    $("input").css("background-color","yellow");
  });
  $("input").keyup(function(){
    $("input").css("background-color","pink");
  });
}); */
</script>
</head>

<html>
<head>
</head>
<body bgcolor="green">
    <!-- <h1>Welcome to Astro vedic</h1>
    <h2>Register a Customer</h2> -->
    <div class="errors" style="width: 500px">
    <s:token></s:token>
    </div>
<s:if test="hasActionErrors()">
   <div class="errors">
      <s:actionerror/>
   </div>
</s:if>
<s:form action="registerCustomer.do" focusElement="focus" method="post" validate="true" namespace="/">
<s:actionerror /> 
            <s:textfield id="focus" name="name" key="name" size="20" />
            <s:password name="password" label="Password "/>
            <s:password name="confirmPassword" label="Re-enter Password "/>
            <s:textfield name="email" key="email" size="20" required="true" />
             <s:textfield name="telephone" key="telephone" size="20"></s:textfield> 
            <s:select required="true" name="countryCode" label="CountryName" listValue="name" headerKey="" headerValue="Choose One"
            list="countryList" listKey="value"/>  
            <s:submit align="center" key="addCustomer"/>

        </s:form>
    </div>
</body>
</html>

dojo\.*,^struts\*
输入、返回、取消、浏览
输入、返回、取消、浏览
成功信息
/登记牌
/regSuccess.tiles
/登录成功
/loginForm.tiles
/loginForm.tiles
/loginForm.tiles
/loginForm.tiles
/接触瓷砖
/接触瓷砖
/联系我们
/联系成功
customer.jsp:

package com.astro.action;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.*;
import javax.servlet.*;
import com.astro.model.*;

import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.interceptor.validation.SkipValidation;

//import org.hibernate.classic.Validatable;

import com.astro.base.framework.AstroSystemException;
import com.astro.bo.CustomerBo;
import com.astro.model.Customer;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.Validateable;

public class CustomerAction extends ActionSupport implements  Serializable,SessionAware,Preparable, ModelDriven<CustomerPageInfo>{
    private static final long serialVersionUID = 2335707118972931221L;

    private Map<String,Object> session;
    String target = "";
    //DI via Spring

    private CustomerPageInfo model;
    private CustomerBo customerBo;
    private Customer customer=new Customer();
    public CustomerBo getCustomerBo() {
        return customerBo;
    }
    public void setCustomerBo(CustomerBo customerBo) {
        this.customerBo = customerBo;
    }

    public String errorDisplay()
    {
        return "input";
    }
    //Register a Customer
            public String register() throws Exception{
                System.out.println("I am in register method of CustomerAction.java");
                System.out.println("((())))"+model.getCountryList().toString());
                System.out.println("((())))"+model.getCustomerInfo());
                model.getCustomerInfo().setCreatedDate(new Date());
                 customerBo.register(customer);
                return SUCCESS;
                }

    public void prepare() throws Exception {
        if(model==null)
        {
            model=new CustomerPageInfo();
            System.out.println("In prepare method");
            if(model.getCountryList()==null)
            {
                List<NameValuePair> countryList=customerBo.getAllCountries();
                model.setCountryList(countryList);
            }
            System.out.println("Before initializing"+model.getCustomerInfo());
            if(model.getCustomerInfo()==null)
            {
                model.setCustomerInfo(customer);
            }
            System.out.println("After initializing"+model.getCustomerInfo());
        }

    }

    @Override
    public void setSession(Map<String, Object> map) {
        this.session=map;
    }

    /*public void validate()
    {
        try {
            if(customerBo.doesCustomerExists(customer)==true)
            {
                addActionError("Customer Alreay Exists");
            }
            else
            {
                addActionMessage(INPUT);
            }
        } catch (AstroSystemException e) {
            e.printStackTrace();
        }

    }
*/
    public void setModel(CustomerPageInfo model)
    {

    this.model=model;
    }

    public CustomerPageInfo getModel()
    {
        return model;
    }
}
<?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.devMode" value="true" />
    <constant name="struts.configuration.xml.reload" value="true" />
    <constant name="struts.action.extension" value="do" />
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.custom.i18n.resources" value="ApplicationResources" />
    <!-- <constant name="struts.freemarker.mru.max.strong.size" value="250" /> -->
    <constant name="struts.freemarker.templatesCache.updateDelay"
        value="60000" />
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />

    <package name="astro" extends="struts-default" namespace="/">

        <!-- Different types of result types -->
        <result-types>
            <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>

        <interceptors>
                <interceptor-stack name="defaultStack">
                <interceptor-ref name="exception"/>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="servletConfig"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="debugging"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="checkbox"/>
                <interceptor-ref name="multiselect"/>
                <interceptor-ref name="actionMappingParams"/>
                <interceptor-ref name="params">
                  <param name="excludeParams">dojo\..*,^struts\..*</param>
                </interceptor-ref>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="validation">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
            </interceptor-stack>

        </interceptors>
         <action name="registerCustomer" class="customerAction" method="register"> 
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="redirectAction">
                <param name="actionName">successInformation</param>
            </result>
            <result name="input" type="tiles">/registration.tiles</result>
        </action>

        <action name="successInformation" class="com.astro.action.DisplayAction"
            method="display">
            <interceptor-ref name="defaultStack"/>
            <result name="success" type="tiles">/regSuccess.tiles</result>
        </action>

        <action name="loginCustomer" class="loginAction" method="login">
            <result name="success" type="tiles">/loginSuccess.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="loginCustomer1" class="loginAction" method="logout">
            <result name="success" type="tiles">/loginForm.tiles</result>
            <result name="input" type="tiles">/loginForm.tiles</result>
        </action>

        <action name="login" class="com.astro.action.DisplayAction1"
            method="display">
            <result name="success" type="tiles">/loginForm.tiles</result>
        </action>
        <action name="feedback" class="com.astro.action.DisplayAction1"
            method="display1">
            <result name="success" type="tiles">/contact.tiles</result>
            <result name="input" type="tiles">/contact.tiles</result>
        </action>
        <action name="contactus" class="contactAction" method="contact">
            <result name="success" type="tiles">/contactus.tiles</result>
            <result name="input" type="tiles">/contactsuccess.tiles
            </result>
        </action>
    </package>

</struts>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page session="false"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<style type="text/css">
@import url(css/main.css);
</style>
<style>
.errorMessage {
    color: red;
}
.errors {
    background-color:#FFCCCC;
    border:1px solid #CC0000;
    width:400px;
    margin-bottom:8px;
    font: message-box;
}
.errors li{ 
    list-style: none; 
    }
</style>
<style type="text/css">
.errorsBg{
    background-color:;
    color:black;    
    border: 0px solid;
}

.errorMessage{
    padding:4px 8px;
}

 table{
    border-spacing: 8px;
} 
td{
    padding:5px;
}
</style>
<script>
/* $(document).ready(function(){
  $("input").keydown(function(){
    $("input").css("background-color","yellow");
  });
  $("input").keyup(function(){
    $("input").css("background-color","pink");
  });
}); */
</script>
</head>

<html>
<head>
</head>
<body bgcolor="green">
    <!-- <h1>Welcome to Astro vedic</h1>
    <h2>Register a Customer</h2> -->
    <div class="errors" style="width: 500px">
    <s:token></s:token>
    </div>
<s:if test="hasActionErrors()">
   <div class="errors">
      <s:actionerror/>
   </div>
</s:if>
<s:form action="registerCustomer.do" focusElement="focus" method="post" validate="true" namespace="/">
<s:actionerror /> 
            <s:textfield id="focus" name="name" key="name" size="20" />
            <s:password name="password" label="Password "/>
            <s:password name="confirmPassword" label="Re-enter Password "/>
            <s:textfield name="email" key="email" size="20" required="true" />
             <s:textfield name="telephone" key="telephone" size="20"></s:textfield> 
            <s:select required="true" name="countryCode" label="CountryName" listValue="name" headerKey="" headerValue="Choose One"
            list="countryList" listKey="value"/>  
            <s:submit align="center" key="addCustomer"/>

        </s:form>
    </div>
</body>
</html>

@导入url(css/main.css);
.errorMessage{
颜色:红色;
}
.错误{
背景色:#FFCCCC;
边框:1px实心#CC0000;
宽度:400px;
边缘底部:8px;
字体:消息框;
}
.li{
列表样式:无;
}
.errorsBg{
背景色:;
颜色:黑色;
边框:0px实心;
}
.errorMessage{
填充:4px8px;
}
桌子{
边界间距:8px;
} 
运输署{
填充物:5px;
}
/*$(文档).ready(函数(){
$(“输入”).keydown(函数(){
$(“输入”).css(“背景色”、“黄色”);
});
$(“输入”).keyup(函数(){
$(“输入”).css(“背景色”、“粉色”);
});
}); */
当我运行代码时,它将准备方法,而不是注册方法。不仅如此,如果我删除customerAction-validation.xml,那么它将注册方法,但数据库中不会保存任何内容

Prepare方法被调用两次。我不知道如何调用register方法并保存客户详细信息。

prepare()
中检查
model

model
将由Params Interceptor设置(ModelDriven Interceptor也应该包括在内,不确定如何设置,因为我从未使用过ModelDriven),它将在之后运行