JSP页面不显示错误信息(Struts问题)
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.host.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.host.struts.form.MyActionForm;
/**
* MyEclipse Struts
* Creation date: 01-18-2008
*
* XDoclet definition:
* @struts.action path="/myAction" name="myActionForm" input="/index.jsp" scope="request" validate="true"
*/
public class MyActionAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// MyActionForm myActionForm = (MyActionForm) form;// TODO Auto-generated method stub
return mapping.findForward("success");
//return null;
}
}
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.host.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
/**
* MyEclipse Struts
* Creation date: 01-18-2008
*
* XDoclet definition:
* @struts.form name="myActionForm"
*/
public class MyActionForm extends ActionForm {
/*
* Generated fields
*/
/**
*
*/
private static final long serialVersionUID = 1L;
/** name property */
private String name;
/*
* Generated Methods
*/
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
ActionErrors errors=new ActionErrors();
if(name.length()<1 || name==null)
{
errors.add("error",new ActionMessage("姓名不能为空"));
}
return errors;
}
/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
this.setName("");
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans >
<form-bean name="myActionForm" type="com.host.struts.form.MyActionForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="myActionForm"
input="/index.jsp"
name="myActionForm"
path="/myAction"
scope="request"
type="com.host.struts.action.MyActionAction" >
<forward name="success" path="/ok.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="com.host.struts.ApplicationResources" />
</struts-config>
搞了好久.不知哪有问题............