java吧 关注:1,237,506贴子:12,707,118
  • 5回复贴,共1

大神求助,java后台向前台传值,不显示的问题

取消只看楼主收藏回复

try {
//TODO 取得所有字段
String sql = "Select MAIN_SERVER1 FROM MAPS_CMS_DB_CONN where MAPS_UID='"
+ maps_uid + "' AND MAPS_PASS = '" + passWord + "'";
String xml;
xml = webservers.selDepartmentMessage(sql, cmsid,
serverAddress);
branchreturnList = (ArrayList<Map<String, Object>>) xmltolist
.xml2List(xml);
if (branchreturnList.isEmpty()) {
response.getWriter().print("2");
} else {
String syncSever1 = (String) branchreturnList.get(0)
.get("MAIN_SERVER1");
request.setAttribute("serverAddress",syncSever1);
response.getWriter().print("1");
}
} catch (Exception e) {
e.printStackTrace();
}
//返回前台
request.getRequestDispatcher("index.jsp").forward(request,response);


IP属地:辽宁1楼2016-09-05 19:20回复
    前台代码:
    <tr style="height:30px">
    <td>远程服务器地址</td>
    <td colspan="3"><input id="serverAddress"
    name="serverAddress" type="text" style="width:100%"
    value=<%=serverAddress%>></input></td>
    </tr>


    IP属地:辽宁2楼2016-09-05 19:25
    回复
      session用过了,不好用。


      IP属地:辽宁3楼2016-09-05 19:26
      回复
        有大神吗?


        IP属地:辽宁4楼2016-09-05 19:34
        回复
          置顶


          IP属地:辽宁8楼2016-09-05 20:32
          回复
            /**
            连接测试
            **/
            function serverTest() {
            var maps_uid = document.getElementById("maps_uid").value;
            var passWord = document.getElementById("passWord").value;
            var url = "./saveServer?btnFlag=1&maps_uid="+maps_uid+"&passWord="+passWord;
            //创建一个XMLHttpRequest对象req 请求后台
            if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            }
            req.open("POST", url, true);
            req.onreadystatechange = calltest;
            req.send();
            }
            前台调用后台方法。


            IP属地:辽宁9楼2016-09-05 20:59
            回复