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%>'

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-07-26
  • 2022-12-23
  • 2019-03-12
  • 2022-12-23
猜你喜欢
  • 2021-11-13
  • 2022-12-23
  • 2021-11-13
  • 2022-01-08
  • 2021-10-30
  • 2021-10-08
  • 2022-12-23
相关资源
相似解决方案