a.jsp提交到action 以后再返回到a.jsp,要求a.jsp中文本框内容不变,一直显示提交前的内容

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【miaomiao_liming】截止到2008-07-29 12:56:41的历史汇总数据(不包括此帖):
    发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:---------------------结分的百分比:---------------------
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    把这个值带着,在action里request.setAttribute("aaa",值);
      

  3.   

    在A.JPS里设默认值.判断默认值是非曲直否为NULL,如果为NULL显示空格,否则显示内容.
      

  4.   


    然后页面再用getAttribute得到
      

  5.   

    ..........
    用struts标签即可
    <html:form action="对应STRUTS里设定的ACTION和FORM" >
    <html:text property="Form属性" ... />
    ...
    </html:form>提交后如果返回来,里面的值还在的.这是1.2里的做法你可以去参考Jpetstore,自己改一下BASEACTION,这样以后写的时候可以直接用FORM来代替ACTION使用.
      

  6.   

    我看还是贴一下吧,这是参考Jpetstore改的一个BaseAction
    BaseAction.javapublic class BeanAction extends Action {
    private Map<String, Method> methods = new HashMap<String, Method>();

    @SuppressWarnings("unchecked")
    private Method getMethod(Class formClass, String methodName) {
    String key = formClass.getName() + "." + methodName;
    Method method = methods.get(key);
    if (method == null) {
    try {
    method = formClass.getMethod(methodName, (Class[]) null);
    methods.put(key, method);
    }
    catch (SecurityException e) {
    e.printStackTrace();
    }
    catch (NoSuchMethodException e) {
    e.printStackTrace();
    }
    }
    return method;
    }

      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          throws Exception {    ActionForward forward = mapping.findForward("success");    try {      //ActionContext.initialize(request, response);      if (form != null) {       if(form instanceof BaseBean){
           ((BaseBean) form).initForm(mapping, request, response);
           }
            // Explicit Method Mapping
            Method method = null;
            String methodName = mapping.getParameter();
            
            if (methodName != null && !"*".equals(methodName)) {
              try {
                method = getMethod(form.getClass(), methodName); // form.getClass().getMethod(methodName, null);
                forward = (ActionForward) method.invoke(form, (Object[]) null);
              } catch (Exception e) {
                //throw new BeanActionException("Error dispatching bean action via method parameter ('" + methodName + "').  Cause: " + e, e);
             e.printStackTrace();
              }
            }        // Path Based Method Mapping
            if (method == null && !"*".equals(methodName)) {
              methodName = mapping.getPath();
              if (methodName.length() > 1) {
                int slash = methodName.lastIndexOf("/") + 1;
                methodName = methodName.substring(slash);
                if (methodName.length() > 0) {
                  try {
                    method = getMethod(form.getClass(), methodName);//form.getClass().getMethod(methodName, null);
    //               method = form.getClass().getMethod(methodName, null);
    //               forward = (ActionForward) method.invoke(form, null);
                    forward = (ActionForward) method.invoke(form, (Object[]) null);
                  } catch (Exception e) {
                    //throw new BeanActionException("Error dispatching bean action via URL pattern ('" + methodName + "').  Cause: " + e, e);
                    e.printStackTrace();
                  }
                }
              }
            }
          }    } catch (Exception e) {
          //request.setAttribute("BeanActionException", e);
          throw e;
        }    return forward;
      }}
    再来个BaseBean.javapublic abstract class BaseBean extends ActionForm { protected HttpServletRequest  request;
    protected HttpServletResponse  response;
    protected ActionMapping  mapping;
    protected ServletContext servletContext;
    protected HttpSession session;
      
    public void initForm(ActionMapping mapping, HttpServletRequest request,
    HttpServletResponse response) {
    this.request = request;
    this.response = response;
    this.mapping = mapping;
    this.session = this.request.getSession();
    this.servletContext = this.session.getServletContext();
    }

    public void validate() {
    } public void reset() {
    } public void clear() {
    }}
      

  7.   

    既然是action,struts组件就可以了..dispatcher