[英]Struts2 jQuery plugin - submit button
我有 Struts 2 jQuery 插件提交按鈕,當單擊該按鈕時,它不會像 Struts 提交按鈕那樣觸發動作類。 單擊按鈕后我需要保持相同的頁面。請查看以下代碼差異。
Struts 提交按鈕 - 運行良好:
<s:form action="product!list" id="searchForm" theme="simple" method="Post">
<s:submit action="product" method="list" value="Find" />
</s:form>
將 Struts 提交轉換為 Struts-jQuery 提交提交按鈕 - 效果不佳:
<s:form action="product!list" id="searchForm" theme="simple" method="Post" >
<sj:submit />
</s:form>
如果只使用表單操作<sj:submit/>
,頁面刷新並作為 Struts 標簽工作,但它不應該是。
為了<sj:submit>
正常工作,必須將targets
屬性設置為某個值,並且表單必須具有id
屬性。
<s:form action="product!list" id="searchForm">
<sj:submit targets="results"/>
</s:form>
您應該在<head>
的正文中包含<sj:head/>
標簽。 此標簽鏈接頁面上的 JQuery 和stylesheet
以及其他初始內容,沒有它,Ajax 調用不會進行,結果頁面刷新。 請參閱提交標簽SubmitTag 的示例:
<%@ taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> <html> <head> <sj:head/> </head> <body> <s:form id="form" action="AjaxTest"> <input type="textbox" name="data"> <sj:submit value="Submit Form" /> </s:form> </body> </html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.