jsp js action之间的传值

1、struts2 action如何向JSP的JS函数传值

action中定义变量
public class TestAction extends ActionSupport implements ServletRequestAware {
    private String state = "test";
}

JSP的JS函数中引用变量
<script type=text/javascript>
    function getStatus() {
        var t = "${state}";
        alert(t);
    }
</script>

2、struts2 action如何向JSP传值

action中定义变量
public class TestAction extends ActionSupport implements ServletRequestAware {
    private String state = "test";
}

JSP中引用变量
<s:property value="#port.publicPort" />

3、JSP如何向struts2 action的函数传值

JSP中的值在form中通过submit的方式提交到action中,如下:
<form class="form-horizontal">
    <input type="text" name="state" ;
%>

JSP中可以使用下面的方法引用此变量
'<%=userId%>'