下面htm的代码。
<html>
<head> <title>untitled docment</title>
</head>
<body bgcolor="#ffffff">
<form mothod="post" action="formData.jsp" name="test">
<p>text:
<input type="text" name="text">
</p>
<p>integer:
<input type="text" name="integer">
</p>
<p>checkbox:</p>
<p>1:
<input type="checkbox" name="checkbox1" value="1">
</p>
<p>2:
<input type="checkbox" name="checkbox2" value="2">
</p>
<p>radiobutton:</p>
<p>
<input type="radio" name="radiobutton" value="1">
<input type="radio" name="radiobutton" value="2">
<input type="radio" name="radiobutton" value="3">
<input type="radio" name="radiobutton" value="4">
</p>
<p>select:
<select name="select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
</form>
</body>
</html>
<html>
<head> <title>untitled docment</title>
</head>
<body bgcolor="#ffffff">
<form mothod="post" action="formData.jsp" name="test">
<p>text:
<input type="text" name="text">
</p>
<p>integer:
<input type="text" name="integer">
</p>
<p>checkbox:</p>
<p>1:
<input type="checkbox" name="checkbox1" value="1">
</p>
<p>2:
<input type="checkbox" name="checkbox2" value="2">
</p>
<p>radiobutton:</p>
<p>
<input type="radio" name="radiobutton" value="1">
<input type="radio" name="radiobutton" value="2">
<input type="radio" name="radiobutton" value="3">
<input type="radio" name="radiobutton" value="4">
</p>
<p>select:
<select name="select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p>
</form>
</body>
</html>
解决方案 »
- 请教mybatis批量插入
- 一个XFire创建webservice服务端设置超时时间的问题
- 如何统计我的网站的访问量啊?
- myeclipse问题
- 刚在项目中用到javascript 有点郁闷 请大家帮个忙啊
- 关于浏览jsp页面,出现下载jsp文件后再打开问题?
- 可能是显示问题
- 请帮我找一下,在Tomcat要用到的这三个包activation.jar,mail.jar,tools.jar?
- 使用HttpClient模拟登录新浪微博并获取微博中的动态中出现一点问题,希望各位能给点意见!
- 页面刷新的问题
- 急,急,急!!!mySQL的bigblob类型,怎么取出来?
- 共 1 页 共 2 篇 第 页 首页 上一页 下一页 尾页
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain..............ectect
String strRadiobutton,strSelect,strOut,errOut;
Integer intInteger;
int errsCount;
这些初始化的时候全部赋值 "",不要欧阳能够默认的 null,String strText="",strInteger="",strCheckbox1="",strCheckbox2="";
String strRadiobutton="",strSelec=""t,strOut="",errOut="";
Integer intInteger=0;
int errsCount=0;
这些我也试了。 Iteger intInteger=null; :P
还是出错。
下面的程序执行肯定会出错。
因为strText =null,
而null是不支持 length()的。
strText = request.getParameter("text");
if (strText.length()==0){
//向错误信息库中添加信息
errs.addElement(new String("TExt域没有值输入"));
}
(环境是APACHE+TOMCAT+JSP http://localhost/index.htm 成功。 HTTP://locathost:8080/ 也出现TOMCAT的欢迎面)
下面是我的表单位置。就是在APACHE的index.htm 相同的目录。
HTTP://localhost/formData.htm 出现表单。
运得formData.jsp出错。
这两个我都试了。
<%
String strText,strInteger,strCheckbox1,strCheckbox2;
String strRadiobutton,strSelect,strOut,errOut;
Integer intInteger;
int errsCount;
Vector errs = new Vector();
//得到并处理名为TEXT的文本输入
strText = request.getParameter("text");
if ((strText!=null)&&(strText.length()>0)){
}else{
//向错误信息库中添加信息
errs.addElement(new String("TExt域没有值输入"));
}
//得到名为Integer的输入并转化为Integer,同时检查是否数值 try{
strInteger = request.getParameter("integer");
intInteger = Integer.valueOf(strInteger);
}catch(NumberFormatException e){
//向错误信息库中添加信息
errs.addElement(new String("Integer需要输入数字"));
//设为缺省值
intInteger = new Integer(0);
}
//得到Checkbox的输入
strCheckbox1 = request.getParameter("checkbox1");
strCheckbox2 = request.getParameter("checkbox2");
if(strCheckbox1==null){
strCheckbox1 = "没有被选中";
}else{
strCheckbox1= "被选中";
}
if(strCheckbox2==null){
strCheckbox2 = "没有被选中";
}else{
strCheckbox2 = "被选中";
}
//得到radiobutton的值
strRadiobutton = request.getParameter("radiobutton");
if(strRadiobutton==null){
strRadiobutton="没有输入";
errs.addElement(new String("Radionbutton 需要输入"));
}
//得到select的输入
strSelect = request.getParameter("select");
//输出结果
strOut ="textr 的值"+strText;
strOut +="<br>integer的值是:"+intInteger;
strOut +="<br>checkbox1 value is :"+ strCheckbox1;
strOut +="<br>checkbox2 value is :"+ strCheckbox2;
strOut +="<br>radiobutton value is :"+ strRadiobutton;
strOut +="<br>strSelect value is :"+ strSelect+"<br>";
//输出错误
errsCount = errs.size();
errOut = new String("");
for(int i=0;i<errsCount;i++){
errOut += errs.elementAt(i).toString();
errOut += "<br>";
}
//输出结果
out.println("<h1>结果<h1><br>");
out.println(strOut);
if(errsCount!=0){
out.println("<h1>错误</h1><br>");
out.println(errOut);
}
%>