此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【so8610】截止到2008-07-30 20:00:11的历史汇总数据(不包括此帖):
发帖的总数量:1                        发帖的总分数:0                        每贴平均分数:0                        
回帖的总数量:1                        得分贴总数量:0                        回帖的得分率:0%                       
结贴的总数量:1                        结贴的总分数:0                        
无满意结贴数:1                        无满意结贴分:0                        
未结的帖子数:0                        未结的总分数:0                        
结贴的百分比:100.00%               结分的百分比:---------------------
无满意结贴率:100.00%               无满意结分率:---------------------
敬礼!

取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=so8610

解决方案 »

  1.   

    HelloAction.java
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package Hello;//import javax.servlet.http.RequestDispatcher;
    //import javax.servlet.http.ServleException;
    import javax.servlet.http.HttpServletRequest;
    //import javax.servlet.http.HttpSession;
    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 org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import org.apache.struts.util.MessageResources;//import com.myapp.struts.PersonBean;
    //import com.myapp.struts.form.HelloForm;
    /** 
     * @struts.action path="/hello" name="helloForm"
     * input="/form/hello.jsp" scope="request" validate="true"
     */
    public final class HelloAction extends Action {    /* forward name="success" path="" */
        private final static String SUCCESS = "SayHello";    /**
         * This is the action called from the Struts framework.
         * @param mapping The ActionMapping used to select this instance.
         * @param form The optional ActionForm bean for this request.
         * @param request The HTTP Request we are processing.
         * @param response The HTTP Response we are processing.
         * @throws java.lang.Exception
         * @return
         */
        public ActionForward execute(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            MessageResources messages = getResources(request);
            ActionMessages errors = new ActionMessages();
            String userName = (String) ((HelloForm) form).getUserName();        String badUserName = "Monster";        if (userName.equalsIgnoreCase(badUserName)) {
                errors.add("username", new ActionMessage("hello.dont.talk.to.monster",
                        badUserName));
                saveErrors(request, errors);
                return (new ActionForward(mapping.getInput()));
            }
            PersonBean pb = new PersonBean();
            pb.setUserName(userName);
            pb.saveToPersistentStore();        request.setAttribute(Constants.PERSON_KEY, pb);        request.removeAttribute(mapping.getAttribute());        return mapping.findForward("SayHello");    }
    }
      

  2.   

    HelloForm.java/*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package Hello;import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;public final class HelloForm extends ActionForm {    private String userName = null;    public String getUserName() {        return (this.userName);
        }
        public void setUserName(String userName) {        this.userName = userName;
        }
        /**
         * Reset all properties to their default values.
         */
        public void reset(ActionMapping mapping, HttpServletRequest request) {        this.userName = null;
        }    public ActionErrors validate(ActionMapping mapping,
                HttpServletRequest request) {
            ActionErrors errors = new ActionErrors();
            if ((userName == null) || (userName.length() < 1)) {
                errors.add("username", new ActionMessage("hello.no.username.error"));
            }
            return errors;
        }
    }
      

  3.   

    1....hello.jsp<html:text property="UserName" size="16" /> <br>  UserName改为userName2....struts-confighello.HelloForm
    hello.HelloAction第一个Hello是大写的