Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 提交内部文本为xmlHttp.responseText的表单_Javascript_Jquery_Ajax_Jsp_Struts - Fatal编程技术网

Javascript 提交内部文本为xmlHttp.responseText的表单

Javascript 提交内部文本为xmlHttp.responseText的表单,javascript,jquery,ajax,jsp,struts,Javascript,Jquery,Ajax,Jsp,Struts,我制作了一个struts应用程序。 首页是jsp,它有一个表单和一个图像。 如果在字段中输入任何数据并单击图像,它将搜索该特定值的详细信息,并将其打印在同一页的div中。 返回的数据以带有复选框和值的表的形式出现。该表格式位于另一个jsp页面中。 我使用Ajax获取所有值并在同一页面上显示,所以我不需要一直刷新 `document.getElementById("prtCnt").innerHTML=xmlhttp.responseText;` where "prnCnt" is the I

我制作了一个struts应用程序。 首页是jsp,它有一个表单和一个图像。 如果在字段中输入任何数据并单击图像,它将搜索该特定值的详细信息,并将其打印在同一页的div中。 返回的数据以带有复选框和值的表的形式出现。该表格式位于另一个jsp页面中。 我使用
Ajax
获取所有值并在同一页面上显示,所以我不需要一直刷新

`document.getElementById("prtCnt").innerHTML=xmlhttp.responseText;`


where "prnCnt" is the Id of that div.
现在,我想勾选一些复选框并提交整个表单(表单上已有的字段和带有复选框的表值)

我该怎么做呢

abc.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
   <%@taglib uri="/WEB-INF/struts-html" prefix="html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01     Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="ajaxjs.js"></script>
</head>
<script>
function getvalue() {
    var value = document.getElementById("client").value;
    loadContent(value);
}
</script>
<body>
<html:form action="AjaxAction.do" >
    <html:text property="client"  value="ankit"  styleId="client" /> <img
        style="cursor: hand" id="search" src="images/1search.gif"  width="15"
        height="15" border="0" onclick="getvalue()">
     </html:form>
 <div id="prtCnt"></div>
 </body>

</html>`
`

AjaxAction.java

package com.ajax;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class AjaxAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    System.out.println("from action");
    AjaxForm aj = (AjaxForm) actionForm;
    System.out.println(request.getParameter("client"));
    if(aj.getClient()!=null){}
    else
        aj.setClient("ankit");
    //aj.setClient(request.getParameter("client"));

    System.out.println(aj.getClient()+"1111111111111111111111111111111");
    if (aj.getClient().equals("ankit"))
        aj.setDummy("Dummy Value for ankit");
    else if (aj.getClient().equals("arpit"))
        aj.setDummy("Dummy Value for arpit"); 
    else if (aj.getClient().equals("rohit"))
        aj.setDummy("Dummy Value for rohit");
    else{
        aj.setClient("soni");
        aj.setDummy("Dummy Value for soni");
    }
    System.out.println("after setting");
    System.out.println(aj.getClient());
    System.out.println(aj.getDummy());
    request.setAttribute("bean", aj);
    return mapping.findForward("success");
}
}

你能给我们提供一些数据吗?请求/响应是什么样子的?页面的html/js代码是什么?
package com.ajax;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class AjaxAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    System.out.println("from action");
    AjaxForm aj = (AjaxForm) actionForm;
    System.out.println(request.getParameter("client"));
    if(aj.getClient()!=null){}
    else
        aj.setClient("ankit");
    //aj.setClient(request.getParameter("client"));

    System.out.println(aj.getClient()+"1111111111111111111111111111111");
    if (aj.getClient().equals("ankit"))
        aj.setDummy("Dummy Value for ankit");
    else if (aj.getClient().equals("arpit"))
        aj.setDummy("Dummy Value for arpit"); 
    else if (aj.getClient().equals("rohit"))
        aj.setDummy("Dummy Value for rohit");
    else{
        aj.setClient("soni");
        aj.setDummy("Dummy Value for soni");
    }
    System.out.println("after setting");
    System.out.println(aj.getClient());
    System.out.println(aj.getDummy());
    request.setAttribute("bean", aj);
    return mapping.findForward("success");
}
}