request.getParameterValues 出现 [Ljava.lang.String;@ 错误
在实现简单的本地登录系统时,需要把page1.jsp的表单显示在page2.jsp中。
其中获取page1.jsp表单的办法就是在页面1的<form>中加入action="page2.jsp"
like this:
<form name="users_name" action="page2.jsp">
<p>
<label>Name</label>
<input type="text" name="name">
</p>
<p>
<label>Gender</label>
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
</p> <p>
<label>Interest</label>
<input type="checkbox" name="interest" value="Sing">Sing
<input type="checkbox" name="interest" value="Dance">Dance
<input type="checkbox" name="interest" value="Play balls">Play balls
<input type="checkbox" name="interest" value="Play games">Play games
</p>
<p id="buttons">
<input type="submit" value="Submit">
</p>
前两种轻松用request.getParameter()解决
Name:<%=request.getParameter("name")%><br>
Sex:<%=request.getParameter("gender")%><br>
而在获取checkbox 时用request.getParameterValues()却出现了问题
Habits:<%= request.getParameterValues("interest")%><br>
输出时输出了:Habits:[Ljava.lang.String;@5f0df6e9
在网上搜索后发现:getParamerterValues()为获取数组的方法
getParamerterValues与request.getParameter的区别: https://blog.csdn.net/moreorless/article/details/4199677
然后改成for循环输出:
Habits:<%
String[] habits = request.getParameterValues("interest");
for( int i = 0; i<habits.length; i++)
System.out.println(habits[i]);
%><br>
结果被抛出异常:
Type Exception Report
Message An exception occurred processing JSP page /printinfo.jsp at line 20
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /printinfo.jsp at line 20
17: Sex:<%=request.getParameter("gender")%><br>
18: Habits:<%
19: String[] habits = request.getParameterValues("interest");
20: for( int i = 0; i<habits.length; i++)
21: System.out.println(habits[i]);
22: %><br>
23: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:613)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.NullPointerException
org.apache.jsp.printinfo_jsp._jspService(printinfo_jsp.java:101)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:472)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
脑瓜疼。。
说明
habits根本就没收到来自request.getParameterValues("interest")传值
经过多番查找,找到了问题所在
Habits:<%
String[] habits = request.getParameterValues("interest");
if(habits!=null)
{
for(int i=0;i<habits.length;i++)
{
out.print(habits[i]);
}
}
%><br>
原来犯了个非常低级的错误,在获取值的时候没有判断来的值是否为空。。。。
以后千万长记性嗷!!
request.getParameterValues 出现 [Ljava.lang.String;@ 错误的更多相关文章
- Java中调用c/c++语言出现Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/String;)V...错误
错误: Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/S ...
- com.opensymphony.xwork2.ognl.OgnlValueStack] - target is null for setProperty(null, "emailTypeNo", [Ljava.lang.String;@6f205e]
情况1,查询结果未转换为与前台交互的实体类DTO 实体类:EmailTypeDto package com.manage.email.dto; public class EmailTypeDto { ...
- ognl.OgnlException: target is null for setProperty(null, "emailTypeNo", [Ljava.lang.String;@1513fd0)
[com.opensymphony.xwork2.ognl.OgnlValueStack] - Error setting expression 'emaiTypeDto.emailTypeNo' w ...
- 疑难杂症:java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.setXmlVersion(Ljava/lang/String;)V
错误: java.lang.AbstractMethodError: org.apache.xerces.dom.DocumentImpl.setXmlVersion(Ljava/lang/Strin ...
- Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;
异常:Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.co ...
- SpringBoot报错:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
错误:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String ...
- Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z
1.window操作系统的eclipse运行wordcount程序出现如下所示的错误: Exception in thread "main" java.lang.Unsatisfi ...
- org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang
HTTP Status 500 - Handler processing failed; nested exception is java.lang.AbstractMethodError: org. ...
- windows 运行hadoop的WordCount报nativeio.NativeIO$Windows.createDirectoryWithMode0(Ljava/lang/String;I)
window eclipse连接hadoop集群,本地运行wordcount,报以下错误,尝试网络上的方法无果,如:换64JDK,添加hadoop_home,path,以及在hadoop\bin和c: ...
随机推荐
- Linux命令大杂烩
查看linux出口IP curl ifconfig.me scp跨服务器转移文件命令 scp 文件 root@IP:/application/apache-tomcat-8.0.36 回车, ...
- RabbitMQ框架构建系列(二)——RabbitMQ基础知识介绍
上一篇记录了一下AMQP协议,RabbitMQ是一个Erlang开发的AMQP协议的开源实现.这一篇简单的介绍一下RabbitMQ的基本原理. 一.RabbitMQ的特点 1.可靠性:RabbitMQ ...
- redis编译 报告错误 jemalloc/jemalloc.h:没有那个文件或目录 解决.
问题原因:没找到jemalloc头文件. 百度谷歌半天没找到有效的下载地址. github中有 到github下载.jemalloc https://github.com/jemalloc/jemal ...
- jmeter(二十六)生成HTML性能测试报告
性能测试工具Jmeter由于其体积小.使用方便.学习成本低等原因,在现在的性能测试过程中,使用率越来越高,但其本身也有一定的缺点,比如提供的测试结果可视化做的很一般. 不过从3.0版本开始,jmete ...
- js数组中随机选取一个数值!!
var arr = ["太阳光大","成功是优点的发挥","不要小看自己", "口说好话","手心向下是助人& ...
- Mysql [Err] 1292 - Truncated incorrect DOUBLE value
Mysql [Err] 1292 - Truncated incorrect DOUBLE value: 'a' - 苍 - 博客园 https://www.cnblogs.com/cang12138 ...
- JEECG BOOT
JEECGBOOT - 开源搜索 - 开源中国https://www.oschina.net/search?scope=blog&q=JEECGBOOT JEECG 基于代码生成器J2EE智能 ...
- [转帖][超级少儿不宜]一氧化氮(NO),为什么亚洲人是最硬
阴茎科学:一氧化氮(NO),为什么亚洲人是最硬 尼堪巴图鲁 关注他 2,911 人赞同了该文章 https://zhuanlan.zhihu.com/p/55941740 超级少儿不宜.. ...
- Python 安装 (win10)
1. 下载python 网址: python.org 版本: 2.7 安装包名字: Windows x86-64 MSI installer 一路next. 2. 配置环境变量: path 里面添加p ...
- [CQOI2009] 中位数
不错的思维题 传送门:$>here<$ 题意:给出一个N的排列,求出其中有多少个连续子段的中位数是b 数据范围:$N \leq 100000$ $Solution$ 先考虑中位数的意义:一 ...