参数标签给出空值 [英] Param tag giving null value

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

问题描述

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天全站免登陆