我通过js中的方法,获得到了页面上的数据,比如是(1 2 3 4)四个数,然后把这四个数放在一个数组中,我再通过$ajax方法中的post方法把这个数组对象发送给servlet,然后输出servlet接收到的数组对象,发现那四个数之间被逗号隔开了,请问这是什么原因啊?是servlet里面的处理机制直接对数组处理了嘛?
解决方案 »
- 如何使某一已知域名指向我的web服务器?
- 如何判断当前IP是否为某个IP段内IP?
- 如何将不同服务器上的JSP运行结果显示在同一个页面上,求教(急)
- 使用数据库连接池,servlet要操作数据库,取连接跟释放连接难道不是放在init、destroy中的?
- 郁闷不已的<input type="file">引出的问题
- MS SQL SERVER 中查表30-40行怎么查
- 请教几个使用连接池的两个问题
- 关于Jreport和Jsp整合开发(高分相赠)
- 救命啊,我的Jsp为什么不能连接到SqlServer数据库呢?
- javabean如何从数据库获得几个不同的数值,并依次return给jsp页面?有源代码吗,急!!!1
- 使用JSP从两个数据表提取不同的字段 无法显示 在线等
- The server encountered an internal error () that prevented it from fulfilling this request是什么错误
如果servlet中通过request获得数据,那用request.getParameter("url中的名字"),它返回一个字符串数组,你可以自己再做处理假设GET的URL=http://localhost/xxx/xxxServlet?aaa=1&aaa=2&aaa=3&aaa=4
在xxxServlet中doGet方法中使用request.getParameter("aaa")会得到一个1 2 3 4 的字符串数组
package cn.com.year2009.month04.day07;import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2009-4-7
* Time: 23:29:11
* To change this template use File | Settings | File Templates.
*/
public class TestServlet extends HttpServlet { protected void service(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException {
String a=request.getParameter("a");
System.out.println(a); String b[]=request.getParameterValues("a");
for(int i=0;i<b.length;i++){
System.out.println(b[i]);
}
}
}
url = http://localhost:7001/web/TestServlet?a=1&a=2
打印结果
1
1
2