jsp如何获取表单里输入的数字
20171011-night.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<form action="" method=get name=form>
<input type="text" name="mnew" value="请输入一个数字">
<input type="submit" value="送出" name=submit>
</form>
<%
String n=request.getParameter("mnew");%>
<p>include file</p>
<jsp:include page="171011-hello.jsp" >
<jsp:param name="number" value="<%=n %>" />
</jsp:include>
</body>
</html>
20171011-hello.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
你好!你好!
<% String str=request.getParameter("number");
double n=Double.parseDouble(str);
int sum=0;
for(int i=0;i<=n;i++)
{
sum=sum+i;
}
n=sum;
%>
从1加到n的值为:<%=n
%>
</body>
</html>
运行第一个jsp时一直不行,肯定是获取表单数据的时候出了问题但是我不知道怎么改。。