我正在尝试将3个值转发到另一个JSP页面,在这个页面中它们将相乘并显示结果。单击提交按钮不会执行任何操作。
JSP Page 1:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Simple Interest Page</title>
</head>
<body bgcolor="pink">
<%@ include file="header.jsp" %>
<center>
<form name="calcsimple.jsp" method="post">
<h5 style="font-size: 150%">Simple Interest Page</h5>
Principal Amount:<input type="number" name="pr" value=""/>
Interest Rate:<input type="number" name="ir" value=""/>
Time Period:<input type="number" name="tp" value=""/>
<input type="submit" name="submit" value="submit"/>
</form>
</center>
<%@include file="footer.jsp" %>
</body>
calcsimple.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Result</title>
</head>
<%
int result=0;
String s1=request.getParameter("pr");
String s2=request.getParameter("ir");
String s3=request.getParameter("tp");
if(request.getParameter("submit")!=null)
{ result=Integer.parseInt(s1)*Integer.parseInt(s2)*Integer.parseInt(s3);
}
%>
result=<%= result+""%>
</html>
答案 0 :(得分:1)
问题可能是因为你没有采取&#34;行动&#34;形式,把&#34;名称&#34;代替。它应该是action='calcsimple.jsp'
希望它对你有所帮助! :)