jsp参数传递计算 我在1.jsp页面把用户填写的单价,数量用session传到2.jsp页面,我想把1.jsp页面的数据传到2.jsp时显示的是单价*数量(或者说是总价)。新手,请详细说说谢了。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 还有,参数传递不要用sessioin,而是用表单提交到 2.jsp就行了。比如1.jsp<form method="post" action="2.jsp">价格:<input type="text" name="price"/>数量:<input type="text" name="qty"/><input type="submit"/></form>2.jsp double price = 0; double qty = 0; try{ price = Double.parseDouble(request.getParameter("price")); }catch(Exception ex){ price = 0; } try{ qty = Double.parseDouble(request.getParameter("qty")); }catch(Exception ex){ qty= 0; } out.println(qty*price); double price = 0; double qty = 0; try{ price = Double.parseDouble(request.getParameter("price")); }catch(Exception ex){ price = 0; } try{ qty = Double.parseDouble((String)session.getAttribute("qty"));//通过session取得数量 }catch(Exception ex){ qty= 0; } out.println(qty*price); 1.jsp<%session.setAttribute("count",count);%>2.jsp<%=session.getAttribute("count");%>这样就能把1.jsp的东西在2.jsp中取到! 1.jsp页面代码type<input type="radio" name="type" value="10"/><input type="radio" name="type" value="20"/><input type="radio" name="type" value="30"/>price <input type="text" name="price" />category <select name="category"> <option value="7.8">aaa</option> <option value="9.3">bbb</option> </select>到了2.jsp我想得到他们的总价应该怎样呢?总价是type*price*category 关于网站建设 求助 Ext4 动态tree如何加载(后台action怎么写) 一个乱码的问题 在SSH中 可以在写一个jdbc吗 httpclient自动登录网站 这到底是什么问题啊,奇怪??!! 论谈发贴的一个问题==>>大家帮帮忙 关于getClass().getResource("/").getPath()路径问题 java实现邮箱激活验证问题 关于配置Tomcat4.1虚拟目录的问题。 Ajax中的一个问题 java 修改数据表字段出错
<form method="post" action="2.jsp">
价格:<input type="text" name="price"/>
数量:<input type="text" name="qty"/>
<input type="submit"/>
</form>2.jsp double price = 0;
double qty = 0;
try{
price = Double.parseDouble(request.getParameter("price"));
}catch(Exception ex){
price = 0;
}
try{
qty = Double.parseDouble(request.getParameter("qty"));
}catch(Exception ex){
qty= 0;
}
out.println(qty*price);
double qty = 0;
try{
price = Double.parseDouble(request.getParameter("price"));
}catch(Exception ex){
price = 0;
}
try{
qty = Double.parseDouble((String)session.getAttribute("qty"));//通过session取得数量
}catch(Exception ex){
qty= 0;
}
out.println(qty*price);
<input type="radio" name="type" value="10"/>
<input type="radio" name="type" value="20"/>
<input type="radio" name="type" value="30"/>
price
<input type="text" name="price" />
category
<select name="category">
<option value="7.8">aaa</option>
<option value="9.3">bbb</option>
</select>
到了2.jsp我想得到他们的总价应该怎样呢?总价是type*price*category