【发布时间】:2013-08-16 09:42:35
【问题描述】:
在我的应用程序中,我需要动态更改<s:textfield> 的内容
我的代码如下:
<script type="text/javascript">
$.subscribe('before', function(event, data) {
$('#text').val('Text Changed by jQuery');
});
</script>
<s:form id="form2" action="textchange" >
<s:textfield id="text" name="text" value="Hello World!!!"/>
<sj:submit targets="result" onBeforeTopics="before" />
</s:form>
我的预期输出是
Text Changed by jQuery
但我得到了
Hello World!!!
我正在使用 Struts2-jQuery-plugin 3.5.1。 如何获取动态输出?
【问题讨论】:
-
你在哪里获得旧值?在您的操作类中还是在 jsp 本身中?
-
将
subscribe放入文档就绪块中。 -
我在 actionclass 中获得了我的旧值
-
你需要ajax调用还是纯提交就够了?
-
我需要使用 sj:submit 进行 ajax 调用。
标签: java jquery jsp struts2 struts2-jquery-plugin