当程序运行完validate方法之后,下面运行什么,我想谁知道的告诉我下,谢谢。
解决方案 »
- 高分求一个基于JS的许愿树功能。
- 求大神解释下这两段js是什么意思啊。
- hibernate spring整合错误
- 请教webserice传递对象和数组
- 有关hibernate 并发的疑惑,求达人指教
- 大侠们救命啊!关于JAVAMAIL的问题
- Spring 的IOC:请教<beans>里的参数意义
- unexpected token: ( near line 1, column 65
- 菜鸟问题:在运行中 command prompt 指令启动德类似DOS窗口是个什么窗口????
- HttpURLConnection 读取网络图片的问题 急求
- JSP 上传文件报错
- jframe透明但是背景图片和上面的jpanel不透明,怎么做的?
<%@ page contentType="text/html;charset=gbk"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<html:html lang="true">
<head>
<title>MLDN —— 我的团</title>
<META NAME="Generator"
CONTENT="Struts + Spring + Hibernate + MySQL + Tomcat + CP">
<META NAME="Author" CONTENT="发大水">
<META NAME="Keywords" CONTENT="范德萨,SSH,tomcat,mysql">
<META NAME="Description" CONTENT="发的飞洒的 —— www.zhinangtuan.net.cn">
</head>
<body>
<center>
<jsp:include flush="true" page="../inc/template.jsp">
<jsp:param name="url" value="../"/>
</jsp:include>
<h1>用户注册</h1>
<html:form action="/jsp/user.do" method="post">
用户ID:<html:text property="userid"></html:text>
<br>
用户密码:<html:password property="userpwd"></html:password>
<br>
确认密码:<html:password property="confirmpwd"></html:password>
<br>
丢失密码提示问题:<html:text property="userques"></html:text>
<br>
丢失密码问题答案:<html:text property="userans"></html:text>
<br>
验证码:<html:text property="checkcode"></html:text>
<img src="image.jsp"><br>
<input type="hidden" name="status" value="register">
<input type="hidden" name="type" value="1">
<html:submit value="注册"></html:submit>
<html:reset value="重置"></html:reset>
</html:form></center>
</body>
</html:html>
UserForm:
public class UserForm extends ActionForm {
/*
* Generated fields
*/ /** id property */
private String id; /** sex property */
private String sex; /** userid property */
private String userid;
/** userpwd property */
private String userpwd;
private String confirmpwd; private String checkcode; /** grade property */
private String grade; /** realname property */
private String realname; /** usermail property */
private String usermail; /** userans property */
private String userans; /** userques property */
private String userques; /** integral property */
private String integral;
private int type;
//1 表示注册功能
/*
* Generated Methods
*/ /**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors=new ActionErrors();
System.out.println("aaaaaaaaaaaaaaaaa");
System.out.println("type====["+type+"]");
if(type==1){
//注册
System.out.println("type==1");
if(this.userid==null||"".equals(this.userid)){
errors.add("userid",new ActionMessage("user.userid.null"));
System.out.println("1111");
}
if (this.userpwd == null || "".equals(this.userpwd)) {
System.out.println("2222");
errors.add("userpwd", new ActionMessage("user.userpwd.null"));
} else {
if (!(this.userpwd.equals(this.confirmpwd))) {
System.out.println("33333");
errors.add("configpwd", new ActionMessage(
"user.confirmpwd.error"));
}
}
if (this.userques == null || "".equals(this.userques)) {
System.out.println("44444");
errors.add("userques", new ActionMessage("user.userques.null"));
}
if (this.userans == null || "".equals(this.userans)) {
System.out.println("555555");
errors.add("userans", new ActionMessage("user.userans.null"));
}
if (this.checkcode == null || "".equals(this.checkcode)) {
System.out.println("666666");
errors.add("checkcode", new ActionMessage("checkcode.null"));
}
}
System.out.println("wwwwwwwwwwwwwwww");
return errors;
} /**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
this.checkcode = "" ;
} /**
* Returns the userpwd.
* @return String
*/
public String getUserpwd() {
return userpwd;
} public String getCheckcode() {
return checkcode;
} public void setCheckcode(String checkcode) {
this.checkcode = checkcode;
} /**
* Set the userpwd.
* @param userpwd The userpwd to set
*/
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
} /**
* Returns the id.
* @return String
*/
public String getId() {
return id;
} /**
* Set the id.
* @param id The id to set
*/
public void setId(String id) {
this.id = id;
} /**
* Returns the sex.
* @return String
*/
public String getSex() {
return sex;
} /**
* Set the sex.
* @param sex The sex to set
*/
public void setSex(String sex) {
this.sex = sex;
} /**
* Returns the userid.
* @return String
*/
public String getUserid() {
return userid;
} /**
* Set the userid.
* @param userid The userid to set
*/
public void setUserid(String userid) {
this.userid = userid;
} /**
* Returns the grade.
* @return String
*/
public String getGrade() {
return grade;
} /**
* Set the grade.
* @param grade The grade to set
*/
public void setGrade(String grade) {
this.grade = grade;
} /**
* Returns the realname.
* @return String
*/
public String getRealname() {
return realname;
} /**
* Set the realname.
* @param realname The realname to set
*/
public void setRealname(String realname) {
this.realname = realname;
}
public String getConfirmpwd() {
return confirmpwd;
} public void setConfirmpwd(String confirmpwd) {
this.confirmpwd = confirmpwd;
} public int getType() {
return type;
} public void setType(int type) {
this.type = type;
}
/**
* Returns the usermail.
* @return String
*/
public String getUsermail() {
return usermail;
} /**
* Set the usermail.
* @param usermail The usermail to set
*/
public void setUsermail(String usermail) {
this.usermail = usermail;
} /**
* Returns the userans.
* @return String
*/
public String getUserans() {
return userans;
} /**
* Set the userans.
* @param userans The userans to set
*/
public void setUserans(String userans) {
this.userans = userans;
} /**
* Returns the userques.
* @return String
*/
public String getUserques() {
return userques;
} /**
* Set the userques.
* @param userques The userques to set
*/
public void setUserques(String userques) {
this.userques = userques;
} /**
* Returns the integral.
* @return String
*/
public String getIntegral() {
return integral;
} /**
* Set the integral.
* @param integral The integral to set
*/
public void setIntegral(String integral) {
this.integral = integral;
}
}
UserAction:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.lxh.myznt.struts.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import org.lxh.myznt.util.MD5Code;
import org.lxh.myznt.vo.User;
import org.lxh.myznt.dao.UserDAO;
import org.lxh.myznt.struts.form.UserForm;
/**
* MyEclipse Struts Creation date: 06-30-2007
*
* XDoclet definition:
*
* @struts.action path="/user" name="userForm" input="/form/user.jsp"
* parameter="status" scope="request" validate="true"
*/
public class UserAction extends DispatchAction {
private UserDAO userdao; public UserDAO getUserDAO() {
return userdao;
} public void setUserDAO(UserDAO userDAO) {
this.userdao = userDAO;
} public ActionForward register(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.print("........................................进入action.....................");
UserForm userForm = (UserForm) form;
// 先判断验证码是否正确
String ccode = (String) request.getSession().getAttribute("ccode");
String checkcode = userForm.getCheckcode();
if (!(checkcode.equals(ccode))) {
ActionMessages errors = new ActionMessages();
errors.add("checkcode", new ActionMessage("checkcode.error"));
super.saveErrors(request, errors);
return mapping.getInputForward();
}
// 如果正确,则需要向数据库中插入
MD5Code md5=new MD5Code();
User user = new User();
user.setUserid(userForm.getUserid());
user.setUserpwd(md5.getMD5ofStr(userForm.getUserpwd()));
user.setUserques(userForm.getUserques());
user.setUserans(userForm.getUserans());
user.setGrade(1);
// 查询此用户是否存在
try {
this.userdao.registor(user);
// 成功之后要将用户名和用户等级保存在session之中
request.getSession().setAttribute("userid", user.getUserid());
request.getSession().setAttribute("grade", user.getGrade());
return mapping.findForward("registersuccess");
} catch (Exception e) {
e.printStackTrace();
return mapping.findForward("registerfailure");
}
} public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = new UserForm();
return null;
} public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
UserForm userForm = new UserForm();
return null;
}}struts-config.xml:
<?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="userForm" type="org.lxh.myznt.struts.form.UserForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="userForm"
input="/jsp/error.jsp"
name="userForm"
parameter="status"
path="/jsp/user"
scope="request"
type="org.lxh.myznt.struts.action.UserAction">
<forward name="registersuccess" path="/jsp/index.jsp"></forward>
<forward name="registerfailure" path="/jsp/register.jsp"></forward>
</action> </action-mappings>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
<message-resources parameter="org.lxh.myznt.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/mldn"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<!-- 表示允许自动提交 -->
<prop key="hibernate.connection.autocommit">true</prop>
<!-- 显示sql语句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/lxh/myznt/vo/User.hbm.xml</value></list>
</property></bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>
<bean id="userDAO" class="org.lxh.myznt.dao.UserDAO" abstract="true"></bean>
<bean id="userDAOImpl" class="org.lxh.myznt.dao.impl.UserDAOImpl" parent="userDAO">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<bean name="/jsp/user" class="org.lxh.myznt.struts.action.UserAction">
<property name="userDAO">
<ref bean="userDAOImpl" />
</property>
</bean>
</beans>web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.lxh.myznt.filter.EncodingFilter</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>gbk</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context </servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet </servlet-class>
<load-on-startup>1 </load-on-startup>
</servlet> <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>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
如果你运行了validate,证明你页面上有需要判断的,并且要有对应的input属性。比如在登录界面,在登入之前,我要使用alidate去判断用户是否存在。那么在vaidate方法中运行判断,用户不存在,那么在页面上就会在input属性所对应的地方显示错误,要不就直接运行通过验证的其他action方法。
结果提示HTTP Status 500 - No action instance for path /jsp/user could be created
<bean name="/jsp/user" class="org.lxh.myznt.struts.action.UserAction">
<property name="userDAO">
<ref bean="userDAOImpl" />
</property>
</bean>
程序在这就出问题了。
现在提交之后显示空白页,而且没有进入action。
我一向是将多余的干掉,