我得到了上述相同的解决方案,特此我在下面分享代码,
详细信息.jsp
<script type="text/javascript">
function onChangeProduct() {/*
var name = $('#product').val();
alert(name);
$.ajax({
type : "POST",
url : "/SampleAjax/getProduct.action",
data : {
prod : name
},
success : function(response) {
// we have the response
$('#productPitch').html(response);
},
error : function(e) {
alert('Error: ' + e);
}
}); */
name=document.getElementById("product").value;
//document.myForm.selectedGroupId.value=groupIds;
var strURL="/SampleAjax/getProduct.action?prod="+name;
if (window.XMLHttpRequest) {
var xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST',strURL , true);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
document.getElementById("productPitch").innerHTML = xmlHttp.responseText;
//document.getElementById("load3").style.display = "none";
//document.getElementById("load").style.display = "block";
}
}
xmlHttp.send(null);
}
</script>
</head>
<body>
Details
<s:form name="sampleDto">
<s:select name="product" id="product" headerKey="0"
headerValue="Select Product" list="#request.Product"
onchange="onChangeProduct()" theme="simple">
</s:select>
</s:form>
<div id="productPitch"></div>
产品.jsp
<select>
<option value="">Select</option>
<c:forEach var="listItems" items="${ProductPitch }">
<option value="<c:out value="${listItems}" />">
<c:out value="${listItems}" />
</option>
</c:forEach>
</select>
行动:
System.out.println("Hi");
ArrayList<String> prodPitch = new ArrayList<String>();
if(null != getProd()){
System.out.println(""+getProd());
prodPitch = sampleBo.getProductPitch(getProd());
}
System.out.println(prodPitch.size());
request.put("ProductPitch", prodPitch);
return "success";