
你好,仅看局部代码是无法了解你每一个变量的具体含义。我告诉你一个调试的方法,
你先在代码中试着将:id = rsgetInt(7);的id打印出来,如在其后面加一句:
Systemoutprintln("id=" + id) ;看看这里的id是你需要的那个不,因为你写select 很容易出现错误。同理你在执行这句的时候<form name=form2 action=saveRevertjspid= <%=id%> method=post onsubmit="return checkForm(this);">先将id=<%=id%>输出一下。看看是否正确传入。
回到题上来,int reply = IntegerparseInt(requestgetParameter("id"));如果获取不到,那么说明你没有正确传入id
servlet中拿到的数据在jsp中如何转成int:
有两种可能,第一种如果是数据绑定在Request对象里面,可通过以下方式转换成int
<%
//在servlet已经将userid数据共享,即 requestsetAttribute("userid",21);
String userid= requestgetgetAttribute("userid");
int id=IntegerparseInt(userid);
%>
如果通过Ajax交换,可调用parseInt("")函数方法来将获取的字符串转成int类型的。
原因可能是通过>
先把requestgetParameter("sex")打印出来看看。
int sex =IntegerparseInt(requestgetParameter("sex"));
你好,请问你是不是说的String attrValue = (String)requestgetAttribute("attrname");通过前台页面传入的属性值转换呢,代码如下:
String attrValue = (String)requestgetAttribute("attrname");int result = 0 ;
if(attrValue != null && !""equals(attrValue)){
result = new Integer(attrValue);
//或者result = IntegerparseInt(attrValue);
}
第2个参必须是Object,int不行。可见你的jdk是14以前的版本,用new Integer(n)就OK了。
requestgetSession()setAttribute("proname", new Integer(n));
以上就是关于request.getParameter("id")参数获取不到问题全部的内容,包括:request.getParameter("id")参数获取不到问题、servlet中拿到的数据在jsp中如何转成int、java中request.getParameter获取textarea中参数长度的问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)