先运行show.htm,在里面输入数字点submit按钮,是对的.而你直接运行show.jsp就会报:
org.apache.jasper.JasperException: null
java.lang.NumberFormatException: null那是因为:
request.getParameter("name")没有值.
org.apache.jasper.JasperException: null
java.lang.NumberFormatException: null那是因为:
request.getParameter("name")没有值.
<form action="show.jsp" method="get">
please input:<input name="name" type="text">
<input name="submit" type="submit">
</form>
试试...
有可能为空,选判断之后再进行处理..
<%@ page contentType="text/html; charset=gb2312" language="java" %>
<html>
<head>
<title>显示次数</title>
</head>
<body>
<form action="show.jsp" method="get">
please input:<input name="name" type="text">
<input name="submit" type="submit">
</form>
<%
if (request.getParameter("name") != null) {
int times=Integer.parseInt(request.getParameter("name"));
for(int i=0;i<times;i++){
out.println("hello!how are you");
}
}
%>
</body>
</html>
这个文件就叫:show.jsp
你试试...