snowgxn 2005年03月25日
帮我看看哪出错了,好多方法都试过了,还是不行...错误信息贴出....谢谢...等待中....
帮我看一下哪出错了
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="regUserForm" type="demo.RegUserForm" />
</form-beans>
<action-mappings>
<action path="/regUserAction" type="demo.RegUserAction" />
</action-mappings>
<message-resources parameter="demo.ApplicationResources" />
</struts-config>

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>WebModule1</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>debugjsp</servlet-name>
<description>Added to compile JSPs with debug info</description>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>classdebuginfo</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>debugjsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
</web-app>

//Action
package demo;
import org.apache.struts.action.*;
import javax.servlet.http.*;

public class RegUserAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
/**@todo: complete the business logic here, this is just a skeleton.*/
ActionErrors errors=new ActionErrors();
RegUserForm regUserForm=(RegUserForm)actionForm;
String account=regUserForm.getAccount();
String password=regUserForm.getPassword();
String email=regUserForm.getEmail();
if(email==null) email="";
if("account".equals(account))
{
errors.add("ACCOUNT_REPEAT", new ActionError("errors account.repeat"));
saveErrors(httpServletRequest, errors);
return actionMapping.getInputForward();
}
return actionMapping.findForward("success");
// throw new java.lang.UnsupportedOperationException("Method perform() not yet implemented.");
}
}

//ActionForm
package demo;

import org.apache.struts.action.*;
import javax.servlet.http.*;

public class RegUserForm extends ActionForm
{
private String account;
private String email;
private String password;
public String getAccount()
{
return account;
}
public void setAccount(String account)
{
this.account=account;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email=email;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password=password;
}
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
/**@todo: finish this method, this is just the skeleton.*/
ActionErrors errors=new ActionErrors();
if(account==null || account.length()<1)
{
errors.add("ACCOUNT_ERROR",new ActionError("error.account.required"));
}
if(password==null || password.length()<1)
{
errors.add("PASSWORD_ERRORS",new ActionError("error.password.required"));
}
return errors;
}
public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
account=null;
password=null;
email=null;

}
}
...全文
31 点赞 收藏 2
写回复
2 条回复

还没有回复,快来抢沙发~

发动态
发帖子
Java EE
创建于2007-09-28

3.7w+

社区成员

22.5w+

社区内容

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区公告
暂无公告