参数标记为空值 [英] Param tag giving null value

查看:188
本文介绍了参数标记为空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

param标签在我使用时提供null

param tag giving null value when i used

System.out.println("Before"+request.getParameter("imeino")); 

<% session.setAttribute("imeino1", request.getParameter("imeino1"));
    System.out.print("BBBBB^^@@"+session.getAttribute("imeino"));
%>
<div style="margin-left: 50px; margin-bottom: 10px;">
</div>
<div class="grid" align="center" style="margin-top: 30px">
<ws:url id="remoteurl" action='userimageGrid' escapeAmp="false"> 
    <ws:param name="imeino" value="66666666666"></ws:param>
</ws:url> 

推荐答案

使用redirectredirectAction结果类型时,参数会丢失.要保留请求参数,您应该使用dispatcher结果类型.这是默认的结果类型,如果您错过了result标记的type属性,将使用此结果类型

Parameters are getting lost when you use redirect or redirectAction result type. To retain request parameters you should use dispatcher result type. This is default result type, and it will be used if you miss type attribute of the result tag, like this

<result>/ThankYou.jsp</result>  

为什么param标记赋予null值.因为该值在添加到URL之前已由OGNL转换为整数值,并且抛出NumberFormatException,因为不能存在这样的整数.该值超过Java中整数值的最大值.您应该在param标记中使用字符串值,例如

Why param tag giving null value. Because the value is converted by OGNL to integer value before adding it to the URL and it throws NumberFormatException because no such integer can exist. The value exceeds the maximum in Java for integer value. You should use string value in param tag, like this

<s:url var="remoteurl" action='userimageGrid' escapeAmp="false"> 
    <s:param name="imeino" value="'66666666666'"/>
</s:url> 
<s:a href="%{#remoteurl}">Call</s:a>

这篇关于参数标记为空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆