function showDep(){
$.ajax({
type: "post",
url: baseURL+"/productGroup/showDep.action",
dataType: "json",
success: function(date){
var selectObj=document.getElementById("udep");
selectObj.options.length=1;
for(var i=0;i<date.length;i++){
var len = selectObj.length;
selectObj.options[len] = new Option(date[i].name, date[i].id);
if('${productGroup.series.id}' == date[i].id){
selectObj.options[len].selected = true;
}
}
}
});
}
<select style="width:175px;" name="productGroup.series.id" id="udep">
<option value="">————請選擇————</option>
</select>
public void showDep()
{
HttpServletResponse response = getResponse();
String json;
String hqlSeries = "from ProductSeries as p where p.type = 1";
List listProdSeries = productSeriesServer.findList(hqlSeries);
json = JsonUtils.listToJSONString(listProdSeries);
PrintWriter out;
try {
response.setCharacterEncoding("UTF-8");
out = response.getWriter();
out.write(json);
} catch (IOException e) {
e.printStackTrace();
}
}