如何在jsp servlet中乘以不同coloumn的值

时间:2015-06-10 12:08:12

标签: jsp servlets

我想将resultSet.getInt(“price”)与resultSet.getInt(“quantity”)相乘

并在我的HTML中给出结果 我该怎么做?我是初学者

2 个答案:

答案 0 :(得分:0)

尝试以下....

<% int price = resultSet.getInt("price");
   int qty = resultSet.getInt("quqntity");
   int value = price * qty;
%>

Result Value (price * quantity)  = <% = value %>

如果您有任何疑问,请与我们联系

答案 1 :(得分:0)

我希望它会有所帮助......!

 <%
int grandtotal=0;
while(resultSet.next()){
int price = resultSet.getInt("price");  
int quantity = resultSet.getInt("quqntity");  
grandtotal =grandtotal+(price * quantity); 
}

%GT;    结果=&LT;%= grandtotal%GT;