jquery .html方法与struts标签库的使用问题

hx_java hx_java 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
目的:实现下拉列表的动态加载
相关技术:jquery1_3_2.js,struts1.2
别的不瞎扯,直接看代码..
界面jquery调用:
function sel_1() {
$("#userName").html("正在加载...");
var url = "<%=path%>/issueAction.do?action=show_name";
$.post(url,{role:'1'},function(data){
$("#userName").html(data);
});
}

要动态加载的select标签
<div id="userName">
<select name="user">
<option value="0">--请选择--</option>
</select>
</div>

后台action调用:
public ActionForward show_name(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
String roel_ = request.getParameter("role");
List list = null;
int role = (roel_ != null) ? Integer.parseInt(roel_) : 1;
list = issue_impl.getNameListByRole(role);
String strResult = "<select name=\"user\"><option value=\"0\">---请选择---</option>";
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Object[] obj = (Object[]) list.get(i);
strResult += "<option value='" + obj[0] + "'>" + (String) obj[1]
+ "</option>";
}
}
strResult += "</select>";
System.out.println(strResult);
out.print(strResult);
return null;
}

问题:使用此标签可以实现动态加载,但是使用:
<div id="userName">
<html:select name="user">
<html:option value="0">--请选择--</html:option>
</html:select>
</div>
只能显示值,而没有下拉列表的效果,请问是什么原因? 大家帮帮忙...

分数不多了,请大家帮帮忙吧
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
hx_java
JavaScript 87,983 成员 224,680 内容