[英]Struts2 action with parameter is not working
我從帶有參數的jQuery調用struts2操作,但未調用操作方法。
但是,如果我調用了不帶參數的操作,那么它就可以完美運行。
調用動作:
$('#redemptionForm').attr('action','sendRedempOTP?pbCardNo='+cardNo+'&mobile='+mobileNumber+'&isSearchByMobileNoFlag='+searchByMobileNoFlag);
Struts2動作細節:
<action name="sendRedempOTP" class="com.ndil.web.redemption.ViewGiftItemSlabsAction"
method="sendOTP">
<interceptor-ref name="basicStack" />
<result name="error">/jsp/balanceinquirymain2.jsp</result>
<result>/jsp/balanceinquirymain2.jsp</result>
</action>
動作類方法:
public String sendOTP() {
LOGGER.info("Send OTP called");
String cardNumber = request.getParameter("pbCardNo");
String mobile = request.getParameter("mobile");
String isSearchByMobileNoFlag = request.getParameter("isSearchByMobileNoFlag");
}
當我調用此操作時,則它不起作用。 我低於異常:
No configuration found for the specified action: 'login' in namespace:
此代碼有什么問題?
我的JSP頁面:
<s:form action="#" validate="true" method="post" id="redemptionForm">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="1" style="background-color: #999">
<tr>
<td style="background-color: #f1f1f1">
<table width="950" border="0" cellpadding="2" cellspacing="0" align="center">
<tr align="center">
<td class="fieldtxt" width="50%" align="right"><s:text name="redeem.cardNo" /></td>
<td width="50%" align="left"><s:property value="giftRedemptionVO.pbCardNo" /></td>
</tr>
<tr align="center">
<td class="fieldtxt" width="50%" align="right"><s:text name="redeem.mobileNo" /></td>
<td width="50%" align="left"><s:property value="giftRedemptionVO.mobileNo" /></td>
</tr>
<tr id="custNameRow" align="center">
<td class="fieldtxt" width="50%" align="right"><s:text name="redeem.total.available.shopping.value" /></td>
<td width="50%" align="left"><s:property value="giftRedemptionVO.totalAvailableAmount" /></td>
</tr>
</td>
</tr>
</table>
<td><s:submit value="Redeem(SendOTP)" cssClass="crt_btn" id="sendOtpButton" theme="simple"
</td>
</tr>
</table>
</s:form>
Strust2不使用這種方式來獲取參數。 您可以這樣嘗試:
public void execute() {
String name = super.getRequest().getParameter("pbCardNo");
System.out.println("name:" + name);
}
或者您可以這樣嘗試:
private String pbCardNo;
public void setPbCardNod(String pbCardNo){}
public String getPbCardNod(){}
也許那可以幫助你
使用POST
發送表單時,表單中的數據已被序列化,因此無需像GET中那樣將值編碼為QueryString參數;
始終將私有屬性與getter和setter一起使用來接收/公開數據,幾乎不需要從請求中讀取數據;
您可能已經將全局INPUT
結果映射到login
操作,並且該結果正在被觸發。 如果是這樣,則由於許多原因是錯誤的:
login
操作不存在 login
操作 為什么使用url發送。 如果您能夠使用javascript。 創造
<s:hiddent id="test" name="test"/>
$('#test').value("your value");
String test;
setTest
getTest
String cardNumber = getTest();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.