问题描述
publicclassRegistActionextendsAction{@OverridepublicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{request.setCharacterEncoding("UTF-8");response.setCharacterEncoding("UTF-8");UserFormuserForm=(UserForm)form;Stringusername=userForm.getUser().getUsername();//解决用户名乱码byte[]b=username.getBytes("iso-8859-1");//先回去使用iso的错误字符串username=newString(b,"UTF-8");//(iso)回退,使用utf-8重编userForm.getUser().setUsername(username);String[]like=userForm.getUser().getLike();for(inti=0;i<like.length;i++){byte[]like1=like[i].getBytes("iso-8859-1");//先回去使用iso的错误字符串like[i]=newString(like1,"UTF-8");//(iso)回退,使用utf-8重编}userForm.getUser().setLike(like);ActionMessageserrors=newActionMessages();if(userForm.getUser().getUsername().trim().equals("aaa")){errors.add("errname",newActionMessage("err.repeated","用户"));//this.saveErrors(request,errors);//returnmapping.getInputForward();}if(!this.isTokenValid(request)){//加入Token无效,例如Session属性中没有Token//添加错误信息errors.add(ActionMessages.GLOBAL_MESSAGE,newActionMessage("表单重复提交",false));}if(!errors.isEmpty()){this.saveErrors(request,errors);//跳转到错误页面returnmapping.getInputForward();}//如果Token有效即Session域中有Token则移除Session域中的Token,然后转到成功页面this.resetToken(request);returnmapping.findForward("success");}}
在Action的execute方法中,对Form进行了转型为UserForm,然后对UserForm进行的编码转换是怎么影响到session域中的Form的呢?