servlet中返回一个list的问题

初学安卓 我现在希望从服务器端获取一个list集合 请问servlet和安卓端 该如何写

0

1个回答

问题太大,不是两三句话能说的完的。建议先学学基础,写写人家的demo,再动笔实现自己的内容。

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
一个servlet返回的问题
一个jsp页面.a.jsp,一个form表单提交到submit这个servletrn rnrnrnrn当我submit这个servlet处理完之后用这个语句继续返回这个jsp页面rngetServletContext().getRequestDispatcher("a.jsp").include(request, response);rn第一个问题:那么是不是request里面还有一个test的参数,其值为1?rn因为a.jsp里还有一个form,rn rnrnrn那个这个form提交到submit2这个servlet的时候,是否可以用rnrequest.getParameter("test")来得到test的值?rn我试过了,得不到。rn那应该用什么方法可以得到上面那个form的值呢?rn或者说怎么设计合理一点?
servlet返回list值的双重循环
例如用户去查询自己的订单得到一个orderlist,rn每一个订单(order)对应一个商品的goodlist,rn如果用户(user_id)去查询已买到的商品,在jsp里如何用servlet返回的orderlist和goodlist查询。rn如同淘宝先forEach所有订单,订单里forEach里面的所有商品[img=http://img.my.csdn.net/uploads/201303/21/1363846991_4608.png][/img]
WebAPI返回一个List
前端: [AllowAnonymous] [HttpGet] public void Test20171218(string myPara) { var client = MyClient.Create(); var resp = client.GetAsync("MyUrl?myPara="+myP
sql中传入一个list,返回一个list
-----------传入数组------返回list<string>---------- String[]sendPersonIdArr=sendPersonId.split(","); List<String>list=staffInfoService.ListPhonesByIds(sendPersonIdAr...
JS 中 怎么获得servlet中返回的list
从数据库中返回的信息存到了list中,我想在js中获得list,下面是代码:rnservlet中的代码:rnpublic void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn response.setContentType("text/html");rn rn SelectDAO selectdao=new SelectDAO();rn List list=selectdao.findAllPro();rn rn PrintWriter out = response.getWriter(); rn out.println(list);rnrnjs中的代码:rnvar result=xmlhttp.responseText;rnrn可以这样写吗?这样写了以后怎么获得list中的内容啊???rn请大家多多指教 谢谢
servlet中返回的中文乱码
[code=Java]rnpublic class GetNameServlet extends HttpServlet rnrn protected void doGet(HttpServletRequest req, HttpServletResponse resp)rn throws ServletException, IOException rn resp.setContentType("text/html;charset=utf-8");rn resp.setCharacterEncoding("utf-8");rn rn PrintWriter out=resp.getWriter();rn BufferedReader reader = new BufferedReader(new FileReader(new File("E:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\ServletPro\\XML\\ProName.xml")));rn String content="";rn while(true)rn String s=reader.readLine();//rn if(s == null)rn break;rn rn content=content+s;rn rnrn out.println(content);rn rnrn protected void doPost(HttpServletRequest req, HttpServletResponse resp)rn throws ServletException, IOException rn doGet(req,resp);rn rnrnrn[/code]rnrnrnservlet中的内容如上所示,读取得文件格式为rnrnrnrnrnrnrnrnrnrnrn我用浏览器访问的时候显示一下内容:rnrnrn rn- rn rn rn rn rn rnrnrn这个乱码如何解决 请指教 谢谢
一个servlet中的问题
大家好,小弟最近遇到个问题,百思不得其解,所以就让大家指点指点,小弟先谢谢了! rn 问题是:假如有这样的一段代码: rn public void doGet(HttpServletRequest request, HttpServletResponse response) rnthrows ServletException, IOException rnString method = request.getParameter("method"); rntry rnThread.sleep(5000); rn rncatch(Exception e) rnSystem.out.println(e.getMessage()); rn rn if(method == 0) rn ................. rn rn if(method == 1) rn ................. rn rn if(method == 2) rn ................. rn rn ...................... rn rn我的理解是: rn 假如有多个线程执行这段代码的时候,当第一个线程来访问这个方法时会在这个方法的堆栈中定义好这个method变量,那么第二个线程来访问这个方法时“这个method变量会被重新定义,也就是说会被重新赋值”,那么之前那个线程在执行下面的if语句时的method的值就会有可能变成第二个线程访问时赋的值,也就是说会出现线程安全问题;但是我开了几个浏览器,试了很多次都没发生那种情况(把String method 放在doGet方法外面声明出现了那中情况) rn 请大家分析分析我的理解有错没?非常感谢!
一个Servlet中的问题
各位老师们好,我刚接触servlet,这里有一个问题要请教一下各位前辈。rnrnServlet中:rnHttpSession session = request.getSession(true);rn ServletContext scx = session.getServletContext();rn scx.setAttribute("session1","MYsession11");rn和rnHttpSession session = request.getSession(true);rn session.setAttribute("session1","MYsession11");rn问题1:rn以上两种方式同样能设定session,那么第一种设定session的方法中为什么要用ServletContext对象来设定session啊?rn问题2:rnServletContext具体含义是什么?rnrn谢谢给位前辈能在百忙之中回答我的问题,谢谢了。 rn
Servlet中的一个问题
package test;rnimport java.lang.*;rnimport java.sql.*;rnimport java.util.*;rnimport java.io.*;rnimport javax.servlet.*;rnrnpublic class ConnectionPoolrnrn private Vector freeConnections = null;rn private Hashtable nowConnections = null;rn private String driverName = "";rn private String jdbcURL = "";rn private int maxConnections = 3;rn rn public ConnectionPool ()rn rn rn rn public void openPool () throws SQLExceptionrn rn tryrn rn nowConnections = new Hashtable (maxConnections);rn freeConnections = new Vector (maxConnections);rn Class.forName (driverName);rn for (int i = 0; i < maxConnections; i ++)rn freeConnections.addElement (DriverManager.getConnection (jdbcURL));rn rn catch (Exception ex)rn rn nowConnections = null;rn freeConnections = null;rn throw new SQLException (ex.toString ());rn rn rnrn public void closePool () throws SQLExceptionrn rn if (nowConnections != null)rn rn for (Enumeration e = nowConnections.elements (); e.hasMoreElements (); )rn ((Connection) e.nextElement ()).close ();rn nowConnections.clear ();rn nowConnections = null;rn rn rn if (freeConnections != null)rn rn for (Enumeration e = freeConnections.elements (); e.hasMoreElements (); )rn ((Connection) e.nextElement ()).close ();rn freeConnections.removeAllElements ();rn freeConnections = null;rn rn rnrn public Connection getConnection () throws SQLExceptionrn rn if (freeConnections == null)rn throw new SQLException ("ConnectionPool还没有建立!");rn if (freeConnections.size () == 0)rn throw new SQLException ("没有空闲的连接,请稍后再请求!");rnrn Connection conn = (Connection) freeConnections.firstElement ();rn freeConnections.removeElement (conn);rn nowConnections.put (Thread.currentThread (), conn);rnrn return conn;rn rn rn public void returnConnection () throws SQLExceptionrn rn Connection conn = (Connection) nowConnections.remove (Thread.currentThread ());rn freeConnections.addElement (conn);rn rnrn public void setPoolSwitch (String on_off) throws ServletExceptionrn rn tryrn rn if (on_off.equalsIgnoreCase ("ON"))rn openPool ();rn if (on_off.equalsIgnoreCase ("OFF"))rn closePool ();rn rn catch (SQLException ex)rn rn throw new ServletException (ex.toString ());rn rn rnrn public void setMaxConnections (int maxConnections)rn rn this.maxConnections = maxConnections;rn rn rn public void setDriverName (String driverName)rn rn this.driverName = driverName;rn rn rn public void setJdbcURL (String jdbcURL)rn rn this.jdbcURL = jdbcURL;rn rnrnrnrn"ConnectionPool.java": Error #: 704 : cannot access directory javax\servlet at line 5, column 1rn"ConnectionPool.java": Error #: 300 : class ServletException not found in class ConnectionPool at line 76, column 54rn"ConnectionPool.java": Error #: 300 : class ServletException not found in class ConnectionPool at line 87, column 14rnrn怎样解决,谢谢rn
在SERVLET中的一个问题
我用response.sendRedirect("url")时带参数不能读出值,网页传给SERVLET可以,但是从SERVLET中传出就不行,比如aaa.jsp?pageNo=1,但值能传入,不能传出,何解
Axis2返回List问题
请问Axis2如何返回List,比如Axis2有一个getAllUser()方法,如何在客户端获取返回的List集合,请各位高手指教!!!
DynaTree返回List的问题
我做了一个List<>的Tree结构,返回是这样的:rn List dyTree = Tdata.GetDyTreeMList();rn object obj = new Success = true, Message = "OK", List = dyTree ;rn return Json(obj, JsonRequestBehavior.AllowGet);rnrn页面上:rn[code=javascript] [/code]rnrn并没有返回树的列表。rn想问下,List<>返回怎么处理显示结构啊?rn我用JsTree试过List<>返回,rn在 success: function (data) rnreturn data.Listrnrn就可以了,但dynaTree不知道怎么做。[color=#008080][/color]
在hibernate 返回List 问题
--DAO rnpublic List queryAll()throws Exception;rn-------------------------------------------------------------------------------------------rn--DAO 实现类.rn public List queryAll() throws Exception rn List all= null;rn String hql ="FROM Dept AS d";rn Query q = this.session.createQuery(hql);rn all=q.list();rn this.session.close();rn return all;rn rn----------------------------------------------------------------------------------------------rn-----action 控制.rn public ActionForward selectAll(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response) rn List alldept = null;rn try rn alldept=(List)DAOFactory.getDeptDAOInstance().queryAll();rn catch (Exception e) rn e.printStackTrace();rn rn rn request.setAttribute("all",alldept);rn System.out.println("...................");rn return mapping.findForward("list");rn rn----------------------------------------------------------------------------------------------rn--------jsp view 页面.rnrn<%@ page language="java" pageEncoding="gbk"%>rnrn<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>rn<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>rn<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>rn<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>rnrnrnrnrn rn rn rn List_dept.jsprnrn rn rn rn rn rn rn rn rn 部门列表清单rn rn rn 部门名称rn 部门所在地rn 业务rn rn rn $dept.dnamern $dept.locrn $dept.businessrn rn rn rn rn rn rn no datalist rn rn rn rnrn--------------------------------------------------------------rn出现的问韪.rn2008-1-15 9:57:43 org.apache.catalina.startup.Catalina startrn信息: Server startup in 14379 msrnHibernate: select dept0_.deptno as deptno1_, dept0_.dname as dname1_, dept0_.loc as loc1_, dept0_.business as business1_ from dept dept0_rn[color=#FF6600]java.lang.ClassCastException: java.util.ArrayListrn at org.lxh.struts.action.DeptAction.selectAll(DeptAction.java:89)[/color]rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)rn at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)rn at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)rn at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)rn at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)rn at java.lang.Thread.run(Unknown Source)rn...................rnrn捡查不出来,郁闷
wcf返回List的问题
问题接续自这个帖子rnrn[url=http://topic.csdn.net/u/20110531/13/e5eb9481-9d58-4e81-88cf-723a312baf0d.html]http://topic.csdn.net/u/20110531/13/e5eb9481-9d58-4e81-88cf-723a312baf0d.html[/url]rnrn现在[color=#FF0000]jquery调用[/color]返回poco这样比较简单的list是可以了rn但是如果T的结构稍微复杂点,比如有个联合主键或者list成员,比如上贴中说的newskind类就不成了rnrnfirefug错误状态为aborted,fiddler则是ReadResponse() failed: The server did not return a response for this request. rnrn看了[url=http://professionalaspnet.com/archive/2010/09/01/ReadResponse_28002900_-failed_3A00_-The-server-did-not-return-a-response-for-this-request_2E00_.aspx]这篇文章[/url]意思似乎是fiddler的504错误并不是程序返回的而是因为fiddler自身返回的rnrn同时,如果通过代码来调用rnIApplicationContext ac = ConfigurationManager.GetSection("spring/context") as IApplicationContext;rnCMS.Service.Contract.IPrivateCmsServiceContract pms = ac["PrivateCmsService"] as CMS.Service.Impl.PrivateCmsService;rnpms.GetNewsKindByApp();rn返回的结果是正确的,看来问题处在jq调用或者wcf的配置上rnrn不知道该如何处理啊~~~~~~~~~rnrnrn
CXF返回List问题
WebService新手,看网上的一些例子,java发布的web service返回List这样的数据类型,好多都要自己重新封装一下数据类型,还要加不少注解,但我试了试cxf,直接用返回List就可以了??当然自己封装数据类型也没错,请问这两者有区别没有??rn看了看cxf官方,没有找到什么具体的文档啊?!只有个泛泛的User Guide,请问学CXF应该从哪些资料入手??
queryforlist返回list问题
queryforlist("select a, b from c")返回的值用Map怎么只可以取到a一个啊?怎么也取不到b的值,怎么样才能把所有的值都取出来嘞
DWR返回list问题
返回字符串和数字都没问题,但返回list或对象的时候就会超时,反不回来。 环境是:jdk1.4.2、resin2.1.1.4rn请高人帮忙rnweb.xml rn rndwr-invoker rnDWR Servlet rnDirect Web Remoter Servlet rnuk.ltd.getahead.dwr.DWRServlet rn rnconfig rnWEB-INF/dwr.xml rn rn rndebug rntrue rn rn rnrndwr.xml rn rn rn rn rn rn rn rn rnrn页面: rnfunction getSex() rninServiceOpenAction.getSex( rncallback:function(data) rnDWRUtil.addOptions("sex",data); rn, rntimeout:10000, rnerrorHandler:function(errorString,exception) rnalert("发生错:"+errorString+"..."+exception); rn rn); rn rn rn rnrnjava: rnpublic List getSex() rnList sexList=new ArrayList(); rnsexList.add("男"); rnsexList.add("女"); rnreturn sexList; rnrn
WebService返回List问题
[WebMethod] rn[XmlInclude(typeof(A))] rn[XmlInclude(typeof(B))] rn[XmlInclude(typeof(List))]rnpublic object Invoke(string objectName, string operationName,params object[] prms)rnrn……rnrnrn用WebService,提供一个通用方法Invoke再通过config和反射调用业务方法,返回数据到object,rn现有一业务方法返回两个对象,一个是类B的实例b,一个是类A实例的List,List lista,rn我将它们组织成new objectb,lista返回,但在客户端得到返回数据后,b没问题,lista却成了一个XmlNode的数组,这是怎么回事?
jquery+ajax返回List问题
[code=JScript]rnjQuery.noConflict(); rnjQuery(document).ready(function () rn /*rn * 加载名单返回类型json—listrn * @param Object datarn */rn var url = "aa.action";rn var params; rn jQuery.getJSON(url,params,function callback(data)rn alert("2");//返回不了rn jQuery.each(data.items,function(i,item)rn jQuery("#maindiv").append(item.cname);rn );//这句有没有问题,我参照jquery+ajax帮助文档写的rn )rn);rn[/code]rn[code=HTML]rn rn[/code]rn[code=Java]rnpackage com.tyut.actions;rnimport java.util.List;rnimport net.sf.json.JSONArray;rnimport com.opensymphony.xwork2.Action;rnimport com.tyut.domain.Candiate;rnimport com.tyut.service.CandiateService;rnrnpublic class CandiateAction rnrn private Candiate candiate;rn rn public Candiate getCandiate() rn return candiate;rn rn rn private JSONArray resulttype;rnrn rn public JSONArray getResulttype() rn return resulttype;rn rnrn public void setResulttype(JSONArray resulttype) rn this.resulttype = resulttype;rn rnrn public void setCandiate(Candiate candiate) rn this.candiate = candiate;rn rn rn public String aa()rn CandiateService candiateService = new CandiateService();rn List candiateList = candiateService.getList();rnrn /*for (Iterator iter = candiateList.iterator(); iter.hasNext();) rnrn Candiate candiate = (Candiate) iter.next(); rn System.out.println(candiate.getCname());rnrn */rn JSONArray jsarry=new JSONArray(); rn jsarry=JSONArray.fromObject(candiateList); rn rn resulttype=jsarry; rn return Action.SUCCESS;rn rnrn[/code]rnrn[code=XML]rn rn rn rn resulttypern rn rn rn[/code]
servlet返回静态网页的问题
用servlet返回一个用户登陆界面,可是在tomcat中输入http://localhost:8080/myWebSite/login时,出现文件下载-警告框,好像把输出页面当成下载页面了。rn通过几次测试,是 那一句有问题,注释掉就可以显示了。可是什么问题呢?rn验证源程序代码如下:rnimport javax.servlet.http.*;rnimport java.io.*;rnrnpublic class Login extends HttpServlet rn //返回用户登陆界面;rn //处理get请求rn public void doGet(HttpServletRequest req, HttpServletResponse res)rn rn tryrn //处理中文乱码rn res.setContentType("html/text;charset=gbk");rn //返回登陆界面静态网页rn PrintWriter pw=res.getWriter();rn pw.println("");rn pw.println("");rn [color=#FF0000]pw.println("");[/color]//注意:action后的是验证文件的url pw.println("用户名: ");rn pw.println(" 密码: ");rn pw.println(" ");rn pw.println("");rn pw.println("");rn pw.println("");rn rn rn catch(Exception e)rn e.printStackTrace();rn rn rn rn //处理post请求rn public void doPost(HttpServletRequest req, HttpServletResponse res)rn this.doGet(req, res);rn rn rnrnrn
servlet的返回数据问题
我做的是往数据库中增加用户的功能rnservlet中的post方法rn[code=java]rnprotected void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn // TODO Auto-generated method stubrn response.setContentType("text/html;charset=UTF-8");rn String type=request.getParameter("type");rn if(type.isEmpty()&&type.equals("1"))rn //增加用户rn ZuserDaoImpl zi=new ZuserDaoImpl();rn boolean rs=zi.addZuser(new ZUser(request.getParameter("zname"), request.getParameter("zpassword")));rn try rn JSONObject ject=new JSONObject();rn ject.put("result", rs);rn PrintWriter out = response.getWriter();rn out.println(ject.toString());rn out.flush();rn out.close();rn catch (JSONException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn rn[/code]rnweb.xml配置rnrn userrn com.zpp.servlet.ZuserServletrn rn rn userrn /userrn rnrn测试链接:rnhttp://localhost:8080/MyAppService/user?type=1&zname=sss&zpassword=123456rn怎么是空白的?
不知所措的servlet返回问题
我做的是一个链接到servlet上去,后代参数。由servlet返回一个excel文件。rnrn但奇怪的是,从数据库中查询出的记录没有第一条(从那个输出可以看到,是从第一条开始的)但在 mysqlaboutfunc 中打印出的查询语句在mysql中执行是没有问题的。rnrn这个令我十分郁闷和头痛。为什么没有第一条????????????????????rn rnimport java.io.*;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport org.apache.poi.hssf.usermodel.*;rnimport org.apache.poi.hssf.util.Region;rn rn public class GenerateExcel extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet rn static final long serialVersionUID = 1L;rn rn protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException rn doPost(request,response);rn rn rn protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException rn String skipnum=request.getParameter("skipnum");rn String starttime=request.getParameter("starttime");rn String endtime=request.getParameter("endtime");rn String cardtype=request.getParameter("cardtype");rn String cardstatus=request.getParameter("cardstatus");rn String cardbalance=request.getParameter("cardbalance");rn rn String emptyserial="";rn String emptyaccount="";rn rn if (starttime==null || endtime==null ||skipnum==null ||cardtype==null ||rn cardstatus==null || cardbalance==null || starttime.equals(endtime))rn rn response.sendRedirect("kadeguanli-kadaochu.jsp");rn return;rn rn rn int skipnumber=Integer.parseInt(skipnum);rn int cardtypeof=Integer.parseInt(cardtype);rn int cardstatusof=Integer.parseInt(cardstatus);rn int cardbalanceof=Integer.parseInt(cardbalance);rn rn response.setContentType("application/vnd.ms-excel");rn rn HSSFWorkbook wbook = new HSSFWorkbook();rn rn HSSFSheet sheet = wbook.createSheet("new sheet");rn rn HSSFRow row= sheet.createRow((short)0);rn HSSFCell cell= row.createCell((short)0);rn cell.setCellValue("卡的信息");rn sheet.addMergedRegion(new Region(0,(short)0,1,(short)6));rn HSSFCellStyle style = wbook.createCellStyle(); rn style.setAlignment(HSSFCellStyle.VERTICAL_CENTER); rn style.setAlignment(HSSFCellStyle.ALIGN_CENTER); rn cell.setCellStyle(style);rn rn row= sheet.createRow((short)2);rn row.createCell((short)0).setCellValue("序 号");rn row.createCell((short)1).setCellValue("序列号");rn row.createCell((short)2).setCellValue("卡 号");rn row.createCell((short)3).setCellValue("激活日期");rn row.createCell((short)4).setCellValue("主持人密码");rn row.createCell((short)5).setCellValue("会员密码");rn row.createCell((short)6).setCellValue("制造时间");rn rn MysqlForExcel myexcel=new MysqlForExcel();rn rn int rett=myexcel.startsearchcardinfo(skipnumber,starttime,endtime,rn emptyserial,emptyaccount,cardtypeof,cardstatusof,cardbalanceof);rn rn if(rett!=0)rn return;rn rn if(myexcel.nextcardinfo()!=0)rn response.sendRedirect("kadeguanli-kadaochu.jsp");rn return;rn rn rn int i=1;rn while(myexcel.nextcardinfo()==0)rn String selserial=myexcel.getcardinfostring("serial_no");rn System.out.println(selserial); [color=#FF0000]//此处输出就从第二天记录输出[/color]rn String selaccount=myexcel.getcardinfostring("card_id");rn String selactivedate=myexcel.getcardinfodate("active_date");rn String selhostpasswd=myexcel.getcardinfostring("host_pwd");rn String selattendpasswd=myexcel.getcardinfostring("attend_pwd");rn String selmkdate=myexcel.getcardinfodate("mk_date");rn rn row=sheet.createRow(i+2);rn row.createCell((short)0).setCellValue(i);rn row.createCell((short)1).setCellValue(selserial);rn row.createCell((short)2).setCellValue(selaccount);rn row.createCell((short)3).setCellValue(selactivedate);rn row.createCell((short)4).setCellValue(selhostpasswd);rn row.createCell((short)5).setCellValue(selattendpasswd);rn row.createCell((short)6).setCellValue(selmkdate);rn i++;rn rn rn OutputStream out = response.getOutputStream();rn wbook.write(out);rn out.close();rn rnrnrnrnrnclass MysqlForExcelrn Connection mysqlconn;rn Statement mysqlstmt;rn ResultSet mysqlres;rn rn private int domysqlconn()rn tryrn Class.forName("com.mysql.jdbc.Driver").newInstance();rn mysqlconn=DriverManager.getConnection(uriparam1,"root","123456");rn mysqlstmt=mysqlconn.createStatement();rn rn catch (Exception e)rn System.out.println("Error:"+e.toString()); rn return -1;rn rn return 0;rn rnrn private int domysqlclose()rn tryrn mysqlstmt.close();rn rn mysqlconn.close();rn catch (Exception e)rn System.out.println("Error:"+e.toString());rn rn return -1;rn rn return 0;rn rnrn rn public int startsearchcardinfo(int skipnum,String starttime,String endtime, String serialno,rn String account, int cardtype,int cardstatus,int cardbalance)rn rn int ret=domysqlconn();rn rn if (ret!=0)rn rn return -100;rn rn rn tryrn String subquerysql="from view_cardinfo where mk_date>='"+starttime+"' and mk_date
servlet返回相对路径问题
已知目录结构如下:rnrnprojectrn|---1rn |---a.htmlrn |---aaarn |---b.jsrn |---c.htmlrn rna.html的内容如下:rnrn...rn rn...rnrn...rnrn当用serlvet的getDispatcher和forward返回的时候,rnrn打开a.html报错:rntype Status reportrnrnmessage /project/servlet/c.htmrnrndescription The requested resource (/project/servlet/c.htm) is not available.rnrn请问servlet的代码应该如何写?
servlet返回问题
rn===请选择=== rn 朝阳区 rn二道区 rn高新区 rn经济开发区 rn宽城区 rn绿园区 rn南关区 rn双阳区 rn汽车产业开发区 rn净月区 rn rn rn rn rn rn rn rn ==请选择== rn rnrn我用servlet查询,返回结果,如返回 南关区 ,我如何让select标签中的值也显示为 南关区呢,rn同理,二级菜单中有xxx社区, 返回结果中也有xxx社区,我又如何控制二级菜单中的显示为xxx社区呢,rn求高人指点
如何返回list中的一个元素
[code=C/C++]rn我想把m_Cells中的符合条件的元素返回,rn可是,在主调函数中,我得到的cell是个空指针,没有任何东西 。。rnrn请问,如何返回list中的一个元素。不是拷贝,我要的是存在list中的那份。rnrnbool HitTest(CPoint downPoint,CCell* cell)rnrn for(list::iterator it = m_Cells.begin();it!=m_Cells.end();++it)rn rn if(it->GetCellRect().PtInRect (downPoint))rn rn cell = &(*it);rn return true;rn rn rn return false;rnrn[/code]
一个使用 AJAX servlet返回EXCEL 问题
[color=#FF0000]AJAX[/color] function clickbtnmakeExcel()rn rn var uri= "GeneratePreCard";rn xmlrequest.open("POST", uri, true); rn xmlrequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");rn xmlrequest.send(null); rn rnrnrnrn[color=#3366FF]SERVLET[/color] protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException rn rn response.setContentType("application/vnd.ms-excel");rn rn response.setCharacterEncoding("UTF-8");rn rn HSSFWorkbook wbook = new HSSFWorkbook();rn HSSFSheet sheet = wbook.createSheet("new sheet");rn sheet.setDefaultColumnWidth((short)18);rn rn HSSFRow row= sheet.createRow((short)0);rn HSSFCell cell= row.createCell((short)0);rn cell.setCellValue("卡的信息");rn sheet.addMergedRegion(new Region(0,(short)0,1,(short)4));rn rn row= sheet.createRow((short)2);rn row.createCell((short)0).setCellValue("序 号");rn row.createCell((short)1).setCellValue("序列号");rn row.createCell((short)2).setCellValue("卡 号");rn row.createCell((short)3).setCellValue("主持人密码");rn row.createCell((short)4).setCellValue("会员密码");rn rn rn OutputStream out = response.getOutputStream();rn wbook.write(out);rn out.close();rn rnrnrn用ajax发送的请求 到服务端,服务端用的servlet处理的。(想直接生成Excel文件到客户端)调试过了,生成的文件没问题,就是没反应,没返回?rn望高手解惑!
求教一个servlet结果返回问题
下面是第一个servlet代码:::::rnpackage com.gem.servlet.day3;rnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnpublic class Login1Servlet1 extends HttpServletrn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn request.setCharacterEncoding("GBK");rn response.setCharacterEncoding("GBK");rn String name = request.getParameter("userName");rn String password = request.getParameter("pwd"); rn Userdao userDao = new UserdaoI();rn User user = userDao.login(name, password); rn response.setContentType("text/html");rn PrintWriter out = response.getWriter();rn out.println("");rn out.println("");rn out.println(" ");rn out.println("");rn out.println(" ");rn if(user == null)rn out.println("用户名或密码错误");rn out.println("重新登陆");rn elsern out.println(" ");rn out.println("");rn out.println("");rn rn out.println(" ");rn out.println("");rn out.flush();rn out.close();rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn this.doGet(request, response);rn rn这段是登陆成功后到一个servlet页面,通过点击“课程信息表管理“这个button到一个jsp页面,就是下面这段代码rn。。。。。。。。。。。。。。。。。。。。。。。。。。。rn<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>rn<%@page import="java.sql.ResultSet"%>rn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rn%>rnrnrnrn rn rn My JSP 'shuru.jsp' starting pagern rn rn rn rn rn rn rn rnrn rn rn rn rn rn 课程编号rn 课程名称rn 学分 rn rn 课程类型rn 请选择rn 公共基础课rn 选修课rn 专业基础课rn 专业课rn rn 考试类型rn 请选择rn 开卷rn 闭卷rn rn rn rn rn rn rn rnrn这边点击确定后提交到另一个servlet中进行数据的插入。。。并把插入的数据返回,代码如下::rnpackage com.gem.servlet.day4;rnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport java.sql.ResultSet;rnrnimport javax.servlet.RequestDispatcher;rnimport javax.servlet.ServletContext;rnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnpublic class CshuruServlet extends HttpServlet rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn ServletContext sc = getServletContext();rn RequestDispatcher rd = null;rn request.setCharacterEncoding("GBK");rn response.setCharacterEncoding("GBK");rn String a = request.getParameter("courid");rn int courid=Integer.parseInt(a);rn String courname = request.getParameter("courname");rn String b=request.getParameter("courcredit");rn int courcredit=Integer.parseInt(b);rn String courtype=request.getParameter("courtype");rn String courexam=request.getParameter("courexam");rn Shuru s=new ShuruI();rn ResultSet r=s.R(courid, courname, courcredit, courtype, courexam);rn request.setAttribute("sc", r);rn rd = sc.getRequestDispatcher("/shuru.jsp"); //定向的页面 rn rd.forward(request, response);rnrnrnpublic void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn this.doGet(request, response);rnrnrn到这儿就是问题的关键,我怎么把结果集取回到jsp页面中。。。。
将List中重复值合并,并返回一个list
一个List中有多个表的对象 表对象有5个字段,所有对象的count字段都为1,现在想把name相等的对象合并,并且count会变成合并了几个就变为几。。。就是List中有10个表对象,其中3个对象的name相等,就把他们合并为8个,并且那个3合一的对象count是3
如何返回一个list对象
//----------------------------------------------rna.hrnrnrnstruct testStructrn int intA;rn double doubleB;rn;rnrnclass arn list testList;rnpublic:rn getList();rn;rnrn请教一下,我该如何编写getList方法,可以返回私有对象testList
Servlet 返回浏览器一个表格
public class BodyServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取输出流 字符流 PrintWriter
在servlet中的list在excel输出!!
/*要加入poi包才能成功*/  /***************生成excel文档***************************/  HSSFWorkbook  workbook    = new HSSFWorkbook();  HSSFSheet   sheet      = workbook.createSheet();  HSSFCellStyle   mainsty
在servlet中的list在excel输出!!
[size=x-large]/*要加入poi包才能成功*/ /***************生成excel文档***************************/ HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); ...
pg中返回list的问题,急
[code=SQL]rnCREATE OR REPLACE FUNCTION getXXXList()rn RETURNS SETOF record ASrn$BODY$rnDECLARE rn result RECORD;rnBEGINrn for result in rn select field1,...rn from table1...rn rn LOOPrn RETURN NEXT result;rn END LOOP;rnENDrn$BODY$rn LANGUAGE 'plpgsql' VOLATILE;rnALTER FUNCTION getXXXList() OWNER TO postgres;rn[/code]rn参考了网上的例子,编译通过了。rn但是测试的时候rn[b]select getXXXXXList()[/b]提示rn[b]RETURN NEXT result;[/b]rn返回类型不正确
SSH 中 关于 Query 返回 list() 问题
rnQuery q = session.createQuery("select a from WareTable as a);rn q.setFirstResult(0);  // 从哪个开始 rn q.setMaxResults(6);   // 结束rnSystem.out.println(q.list()); // 打印出 [7] 注:数据库内部有7条记录rnrnSystem.out.println(q.list().size());//为啥 打印出 1 rnrn/*rn 我在前台 采用 可以得到 6个数据结果rn  System.out.println(q.list()); 应该是 Spring 重写了 toString() 方法 rn  System.out.println(q.list().size()) 我很费解rn  System.out.println((q.list()).size()) 这样也是 1rn*/rnrn我想得到 总记录数 ?? 
dwr 返回 pojo中包含list问题
如题,在使用dwr返回数据时,数据为一个pojo对象,该对象中包含list属性,list中为另一个pojo,但在页面只能得到返回的pojo的属性,可以得到包含pojo中list的长度,这个长度和后台得到的数据长度一样,但遍历该list却得不到值,为null,请问是dwr不支持这样的返回格式,必须要自己重要封装再返回才能行吗?还是我的用法有问题
关于servlet中的数据如何返回问题。
各位好:rn 现在目前有一问题,我形象的跟大家描述一下,希望大家能给我解答一下,感激不尽!先塞塞各位了..rn 具体是这样的:rn 前台jsp页面查询功能,选择好了查询项之后,点击查询,ajax将查询项数据发送到servlet端,进行数据库操作,并且查询出结果。比如说上班的考勤结果。rn 查询出结果以后,自然而然的问题是将结果返回到前台jsp页面并显示以实现异步刷新。rn 我的问题:rn 如何在servlet中对查询的数据进行封装或者是组装,将操作后的整个对象返回到前台,这样,在前台就比较方便了,只需要接受一个对象就可以,然后再将其显示到div中。例如:查询的某一周中周三缺勤,则绘制一张表格显示周一到周天,在相应的周三的框中显示缺勤记录,我是想要这样的效果。rn 刚刚接触ajax,还真是弄不太明白,但是由于手头的工作需要,还必须要做出效果。就只能先应付过去了,恶补是来不及了。rn 相关的关键代码如下,我已经贴出,网各位大神可以帮下忙:rn[code=javascript]rn rn[/code]rn
返回List
<p>rn <p>rn 20周年限定一卡通!<span style="color:#337FE5;">可学Java全部课程</span>,仅售799元(原价10374元),<span style="color:#E53333;">还送漫威正版授权机械键盘+CSDN 20周年限量版T恤+智能编程助手!</span>rn </p>rn <p>rn 点此链接购买:rn </p>rn <table>rn <tbody>rn <tr>rn <td>rn <span style="color:#337FE5;"><a href="https://edu.csdn.net/topic/teachercard?utm_source=jsk20xqy" target="_blank">https://edu.csdn.net/topic/teachercard?utm_source=jsk20xqy</a><br />rn</span>rn </td>rn </tr>rn </tbody>rn </table>rn</p>rn<p>rn <br />rn</p>rn<p>rn 本阶段Java视频教程涵盖JavaWEB 企业级开发所需的Servlet、JSP、MVC 设计模式、EL 表达式、JavaBean、国际化、Cookie和HttpSession、JavaMail等核心技术。并通过书城案例,巩固知识,提供开发能力。rn</p>
servlet中 HibernateSessionFactory.getSession返回null
环境:MyEclipse6.5 + tomcat6.0 + Hibernate + SQL Server 2000 sp4rnWeb工程rn由Hibernate自动生成数据类代码,在servlet类的doPost中调用 Session session = HibernateSessionFactory.getSession();返回nullrn但同样建一个Java Project,在main函数下执行相同代码就通过,不知为什么?rn查了论坛上的帖子,始终没有找到答案。有一个关于oracle的,也是在java工程中通过,在Web工程中getSession()返回null,回答说是“是驱动的问题,我用的是jdk1.6,把class12拷到lib下就可以了,另外使用ojdbc14_g.jar也可以.”rn但SQL Server下的没有。rn是哪里配置不对吗?rnrn
在servlet 中返回web-inf下的页面
req.getRequestDispatcher("WEB-INF/page/httpStatu/sqlerror.html").forward(request,response);
一个html中list的问题
我想实现一个功能,如下所示:rn 我在一张网页中,在左边放一个textbox,中间放一个list,右边放一个list,rn我在textbox输入文字后,一点按钮,就加入到中间的list中,然后在中间的rnlist中选中一项,再按按钮,就加入到右边的list中,再在右边的list中选中rn一项,点下按钮,就弹出一张网页.rn 请问这个流程如何实现!!rn 说得乱了些,请大虾们见谅。rn
相关热词 c#异步发送kafka c#窗体编号 c# 操作二进制文件 c# 反射 机制 c#线程 窗体失去响应 c#角度转弧度 c# 解析gps数据 c# vs设置 语法版本 c# json含回车 c#多线程demo