/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
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 com.yourcompany.struts.form.LoginForm;/**
* MyEclipse Struts
* Creation date: 01-26-2010
*
* XDoclet definition:
* @struts.action path="/login" name="loginForm" input="/form/login.jsp" scope="request" validate="true"
*/
public class LoginAction 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) {
response.setCharacterEncoding("GBK");
LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
String userName = loginForm.getUserName();
ActionMessages errors = new ActionErrors();
if(!userName.equals("abc")) {
errors.add("userName", new ActionMessage("userName_wrong"));
this.saveMessages(request, errors);
return mapping.getInputForward();
}
return mapping.findForward("succ");
}
}
书上原来用的ActionErrors类,看了文档发现不能废弃了,改用了ActionMessages errors = new ActionErrors();,运行了一下在文本框后貌似没有出错信息,应该怎么改
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
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 com.yourcompany.struts.form.LoginForm;/**
* MyEclipse Struts
* Creation date: 01-26-2010
*
* XDoclet definition:
* @struts.action path="/login" name="loginForm" input="/form/login.jsp" scope="request" validate="true"
*/
public class LoginAction 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) {
response.setCharacterEncoding("GBK");
LoginForm loginForm = (LoginForm) form;// TODO Auto-generated method stub
String userName = loginForm.getUserName();
ActionMessages errors = new ActionErrors();
if(!userName.equals("abc")) {
errors.add("userName", new ActionMessage("userName_wrong"));
this.saveMessages(request, errors);
return mapping.getInputForward();
}
return mapping.findForward("succ");
}
}
书上原来用的ActionErrors类,看了文档发现不能废弃了,改用了ActionMessages errors = new ActionErrors();,运行了一下在文本框后貌似没有出错信息,应该怎么改
解决方案 »
- 日本野村证券研究所的次世代框架,有谁做过,能讲解一下吗?以前CSDN下载频道有下的,现在找不到了.
- 关于jndi的一些迷惑
- 十万火急求解决办法
- MyEclipse无法创建数据库表的映射文件
- 请教一个dom4j中的XPath 问题
- 请问!进入weblogic控制台报404错误
- hibernate 中的timestamp 問題 ?
- java List 删除 单选
- 大家把自己去面试JAVA(J2EE)程序员的考题(问题)拿出来大家参考一下不吧
- 如何把jbuilder9里面的EJB2.0的例子在jboss3.2中运行起来
- 解析一个xml文件的时候怎样自动打印其中的几行内容
- 求一个mysql语句。。。。。新年第一求。在线等。
</errors>
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%><html>
<head>
<title>JSP for LoginForm form</title>
</head>
<body>
<html:form action="/login">
userName : <html:text property="userName" />
<html:errors property="userName" />
<br />
<html:submit />
<html:cancel />
</html:form>
</body>
</html>
ApplicationResources.properties# Resources for parameter 'com.yourcompany.struts.ApplicationResources'
# Project Struts3.2.2
userName_wrong = your username is wrong!~