struts2的Action方法中,直接输出js代码
一、Action直接输入js代码
struts2的Action方法,可以没有返回值,void,然后直接out.write("<script>js代码</script>")
out.println("<script>js代码</script>")
?
/** * 验证业务密码--ajax方式 * @author mengxianjun * @throws IOException * @date 2011-6-13 下午01:33:03 */public void checkPwd2() throws IOException{PrintWriter out = this.getResponse().getWriter();String vp = "false";if( valiPass(password2) ){vp = "true";out.write("{\"msg\":\""+vp+"\"}");//反斜杠转义}else{vp = "false";out.write("{\"msg\":\""+vp+"\"}");//反斜杠转义}}?
?
1 楼 lewkinglove 2012-03-31 话说, 你的this.getResponse().getWriter()这个方法是自己实现的还是继承父类的? 父类的名字是?