具体的action 操作如下:
...
String method=req.getParameter("method");
//String id=rf.getId();
String id=req.getParameter("id");
//res.setContentType("text/xml;charset=UTF-8");
res.setHeader("Cache-Control","no-cache");
String strSQL="";
String xml_start="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xml_start+="<selects>";
String xml_end="</selects>";
String xml="<select><value>0</value><text>--</text></select>";
DBCPool dbc= new DBCPool();
Connection conn=dbc.getConnection("wy_manager");
Statement stmt=null;
if(conn!=null){
try{
stmt=conn.createStatement();
}catch(SQLException err){
System.out.println(err.getMessage());
}
}
if(method.equals("g1")){
strSQL="select cityID id,city name from city where father="+id;
}else if(method.equals("g1")){
strSQL="select areaID id,area name from area where father="+id;
}
ResultSet rs=null;
try{
rs=stmt.executeQuery(strSQL);
while(rs.next()){
xml +="<select><value>"+rs.getString("id")+"</value><text>"+rs.getString("name")+"</text></select>";
}
}catch(Exception e){
e.printStackTrace();
}
.. String last_xml=xml_start+xml+xml_end;
try {
res.getWriter().write(last_xml); } catch (Exception e1) {
e1.printStackTrace();
}
--------------------------------------------------
我将数据存储在 response 中.在校检http_request.status==200,信息可以成功返回 不过在查看request.responseXML.documentElement 的时候 返回来的却是 null.
请各位大侠帮忙看看~!是什么原因~!
是不是 这句有问题:res.getWriter().write(last_xml);请大侠们指点迷津~!
...
String method=req.getParameter("method");
//String id=rf.getId();
String id=req.getParameter("id");
//res.setContentType("text/xml;charset=UTF-8");
res.setHeader("Cache-Control","no-cache");
String strSQL="";
String xml_start="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xml_start+="<selects>";
String xml_end="</selects>";
String xml="<select><value>0</value><text>--</text></select>";
DBCPool dbc= new DBCPool();
Connection conn=dbc.getConnection("wy_manager");
Statement stmt=null;
if(conn!=null){
try{
stmt=conn.createStatement();
}catch(SQLException err){
System.out.println(err.getMessage());
}
}
if(method.equals("g1")){
strSQL="select cityID id,city name from city where father="+id;
}else if(method.equals("g1")){
strSQL="select areaID id,area name from area where father="+id;
}
ResultSet rs=null;
try{
rs=stmt.executeQuery(strSQL);
while(rs.next()){
xml +="<select><value>"+rs.getString("id")+"</value><text>"+rs.getString("name")+"</text></select>";
}
}catch(Exception e){
e.printStackTrace();
}
.. String last_xml=xml_start+xml+xml_end;
try {
res.getWriter().write(last_xml); } catch (Exception e1) {
e1.printStackTrace();
}
--------------------------------------------------
我将数据存储在 response 中.在校检http_request.status==200,信息可以成功返回 不过在查看request.responseXML.documentElement 的时候 返回来的却是 null.
请各位大侠帮忙看看~!是什么原因~!
是不是 这句有问题:res.getWriter().write(last_xml);请大侠们指点迷津~!
解决方案 »
- 如果我只知道方法名称,不知道方法接收的参数类型,我怎么样得到这个方法的Method对像?
- 关于servlet的中方法访问的问题
- 用java如何获取对MS Server2005刚刚插入数据的ID值?
- 一个简单的问题,求救
- 关于glassfishv3 下用户登陆验证授权 例子 的问题
- AXIS2的Web Service服务端,用xfire客户端调用报“Could not find a service to invoke.”
- 哪位有 hibernate+struts 的运行成功的示例,请传一份,谢谢!
- 急,谁能帮忙给mail一份《j2ee应用与bea weblogic server》的源代码?
- 我根据以往的经验和代码整理一个数据库持久化工具,请兄弟们多提意见
- [高分]java socket如何传送图片+文字
- 哪有关于spring英文版的书?
- struts + hibernate构建网站的问题
555555555555555555555555555555555
不应该是空的吧~!