在一个ACtion里 有这样的一句代码 request.getServletPath();
我用网址访问的话就出现 java.lang.NullPointerException 的异常,奇怪的是我通过 配置文件中跳转到另一个ACTION里就没有问题 像这样 <action name="gateway" class="com.lx.action.gatewayAction" method="redirect">
<result name="add" type="chain">ACITON名子</result> 这样的型式就没问题,如果直接在gateway里写上 request.getServletPath(); 这句代码就不行 ,request已经是正常通过
ActionContext context = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)this.context.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest");
获得的 ,那跳转后的那个ACTION不报异常,能正常获得跳径。
问题写的有点乱 ,还请各位看官包含!
我用网址访问的话就出现 java.lang.NullPointerException 的异常,奇怪的是我通过 配置文件中跳转到另一个ACTION里就没有问题 像这样 <action name="gateway" class="com.lx.action.gatewayAction" method="redirect">
<result name="add" type="chain">ACITON名子</result> 这样的型式就没问题,如果直接在gateway里写上 request.getServletPath(); 这句代码就不行 ,request已经是正常通过
ActionContext context = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)this.context.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest");
获得的 ,那跳转后的那个ACTION不报异常,能正常获得跳径。
问题写的有点乱 ,还请各位看官包含!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货