调用js方法时把request.getAttribute("message")值传进去function test (message){}
JS中也可以直接用struts中的语句,保证可以编译通过! 赞同zxingchao2009
我在页面上直接写<%=request.getAttribute("message")%> 可以在页面上输出值在页面上这样写的话就报错 <s:textfield name="userName" value='<%=request.getAttribute("message")%>'/> 这个是28行 org.apache.jasper.JasperException: /index.jsp(28,41) Attribute value request.getAttribute("message") is quoted with " which must be escaped when used within the value
<script>
var js_message = '<%=request.getAttribute("message")%>'
alert(js_message );
</script>
这样可行
或者
<script>
var js_message = '<s:property value="message"/>'
alert(js_message );
</script>
这样不行啊 弹出的值是 null
你确信request.getAttribute("message")取到值了吗?
var js_message = '<%=request.getAttribute("message")%>'
这不行吧,request就为null了!
赞同zxingchao2009
<s:textfield name="userName" value='<%=request.getAttribute("message")%>'/> 这个是28行
org.apache.jasper.JasperException: /index.jsp(28,41) Attribute value request.getAttribute("message") is quoted with " which must be escaped when used within the value
为什么用struts2标签出错
value="<%=request.getAttribute('message')%>"和value='<%=request.getAttribute("message")%>'都试过了在struts2标签就出错