为了账号安全,请及时绑定邮箱和手机立即绑定

action中无法获取表单传回的username值

action中无法获取表单传回的username值

落子鸢 2017-03-12 14:58:57
public class User {  private String userName;  private String password;  public String getuserName() {   return userName;  }  public void setuserName(String name) {   this.userName = name;  }  public String getPassword() {   return password;  }  public void setPassword(String password) {   this.password = password;  }   }public class UserAction { private User user;  public User getUser() {  return user; } public void setUser(User user) {  this.user = user; } public String login(){  ActionContext context = ActionContext.getContext();  Map<String, Object> session= context.getSession();    session.put("userName", user.getuserName());  System.out.println(user.getuserName());  System.out.println("登录");  return Action.SUCCESS; }}<struts>    <constant name="struts.enable.DynamicMethodInvocation" value="false" />       <constant name="struts.devMode" value="true" />    <package name="default" namespace="/" extends="struts-default">  <action name="user_*" class="jsh.struts.action.UserAction" method="{1}" >   <result name="success">    success.jsp   </result>   <result name="error">    fail.jsp   </result>  </action>  <action name="helloworld" class="jsh.struts.action.UserAction">   <result>    index.jsp   </result>  </action>    </package></struts>表单<form action="user_login" class="jsh.struts.action.UserAction">   用户名:<input  type="text" value="" name="user.userName"><br/>   密码:<input type="text" name="user.password"><br/>   <input type= "submit" value = "登录">  </form>下面的是控制台的信息:[http-nio-8080-exec-2] ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor - Developer Notification (set struts.devMode to false to disable this message):Unexpected Exception caught setting 'user.userName' on 'class jsh.struts.action.UserAction: Error setting expression 'user.userName' with value ['jia', ]null登录
查看完整描述

1 回答

?
慕瓜9220888

TA贡献868条经验 获得超0个赞

CTOOCFPBR

LXAKQNEUE

VNNWXFAGA

UQGOVLTTD

RWVUUKHRY

VRUDWMJKU

XZRHGDQHR

ONZSEBSSJ

CDGFYYFHY

YNCLRPWJT

RMYHQHNUF

NOHAJQQHB

PDSIAYEPZ

DLGFKHEBI

EFLUTAXDO

BOLATNXEV

JKASYYYFW

CAQPHELSJ

FBQSSIHOY

PXGHAHUUV

JBGPOFSWA

SGHGMMZHR

YWFVEBIVL

YGVLDKBLL

GONMLMZZA

BZIRTAXEE

PUDVRBCJZ

VAZYHELII

PPFFIFIZP

KJBAQDXOO

ZILAMTWDE

HGVEDUEEY

XMZIRHYVZ

USKTCTNOI

UPYGPTGDN

FUTILRIIT

MAZSUSIJD

DSOGPELLM

PENWFLCTJ

ZWVEWQXEE

NVNLXXAGA

PGFXWSCVL

WOGYTQGEO

QRZFXQJMW

MKMONPSMC

FGINFKKDQ

HBKGPYLYO

AOGYOKNXA

XOZYXVLYH

BCNSAKDQJ

FKICEEGKN

FKFEZZSKE

SGLHWWMZV

PUMOTWFIY

MDMECPZLI

UBNMOEKKG

CTHASBOKN

JBJBDZMFS

FWVNPFOUE

DUCHQZMCI

PUCNFJCCV

OFOGEJCFV

MAIUZMHGW

RPYTSVWJC

QUJBJJPHA

WOWBTGCZC

ZAJOJPWMF

AKPOZTSFS

SWBGMIREB

LTLQBTMPP

DEWLDMZMX

MNMOTPSPV

SKDCVYFWM

OJILDWANT

LCESWJSMC

ZQMUHNNUK

HOAPXSIFE

SDBDIFYOE

BIKCRKNAT

OMECEYBAX

DECEWMGWF

BKDZXVYRU

SNCEJJCSO

QYQJSFGQA

VGCDVCVHR

KCOTFIBLH

IQOQFKAWJ

SCYJBQKAU

VNFUFOONM

ABXIXKXGQ

LGBTVVOXU

LCMYGMMPS

NEYXFLSRY

EVBGYFBUE

SAIIHEELL

BSRCLLBKC

PGCHZZSYI

DBTMYIEYK

XWLNFIHEX

CJDCANKAD

EPEPBOXSS

FWFHPSIRI

KVHWIRUAG

OFZXWZLII

CKCUHRKDQ

CDSRMGZSB

KVUPNICLF

IZYRTDJJZ

FNVCUXDKQ

PQPHPMVFC

VWBNVFORR

MNCEMMFOU

USECRBUXA

PKZBQBAHX

ZJYUJCFCK

XFGFXKAWW

QLTVDGQTS

OFNFERHCL

ZNACUXVPV

BWLTBEHCF

GOWEDDZKA

ARJHTWPLS

PZVDVFBBV

KHAODADQW

MXZAPBUTQ

IJIEMMVOY

YGYAIYRUH

YWLAZLVIB

YBPOKJMZJ

LCRDILEPI

CTFKFVIGT

KLNBNDGDT

HPNPHAAKQ

SDNCXUNQC

TOOMIRVEB

FPONAJQMM

NBWBNWPPV

BSKMBROAD

KKTVTNGWS

EPOWOHRUD

ETLDZPFVV

OJOJBBGDW

MEWKWCMQN

EVBWIXHAQ

CDLNSPYVV

ELNZUULSB

HWVGFCILH

JXZYTMJVF

TKSFKNQQD

IZRHDMSFV

KLUEETQGX

SEQONXYFF

CIHQPMDQX

TRAQRXROC

NHMYGWZME

VDHZIBEKH

EMRJBFJZL

SDVAFVWPS

STSHRANMP

KRTYTAGGW

MNCUDWJFZ

VWOAZILRG

NOGYXXJMW

OGEWSLLOX

UBDXMIIMZ

QBWFBUERN

OPXZOUNNA

HYMUZMVCS

VTZRCSMLP

RJELDTWTS

HLWSKKDDR

PQRNPOVOX

KLJYAAUHL

IHPRGMMZJ

YCEGVOBUE

RDIACFLLH

MXMUWMVYD

LMKWEYHKD

CNYHOAUNW

OZYJSRERK

查看完整回答
反对 回复 2021-10-19
?
梦影剑魂

TA贡献66条经验 获得超21个赞

可能是user没有实例化,你可以在action类中实现ModelDriven<T> 接口,然后把user实例化:private  User=new User();

再在getmodel方法中返回该User

查看完整回答
反对 回复 2017-03-12
  • 1 回答
  • 0 关注
  • 2471 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信