Struts 2와 Ajax를 사용합니다. Action 클래스에서 매개 변수를 가져올 수 없습니다. 나는이 같은 양식을 가지고 : 나는 HTTP 리더에서 전송 된 요청을 검토 할 때는Action 클래스의 Struts 2 get 매개 변수
<s:form id="form" onSubmit="sendAjaxRequest();">
<s:textfield name="libelle" label="Libelle" />
<s:textfield name="id" label="id" />
<s:submit value="Valider" />
<s:reset value="Effacer" />
</s:form>
:
Content-length contains libelle=Test&id=13
내 요청이 좋다! 내 액션 클래스에서
:
public class MyAction extends ActionSupport {
private String libelle;
private Integer id;
public String getLibelle() {
return auteur;
}
public void setLibelle(String libelle) {
this.libelle = libelle;
}
public String getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String execute() {
System.out.println("Libelle " + libelle);
System.out.println("Libelle " + this.libelle);
}
}
내 액션 libelle이합니다. libelle은 null입니다. 내가 실수를 저지르고 있는지 나는 모른다. 누군가가 나에게 도움을 줄 수 있다면. 감사.
내 문제가 있지만 해결책이 아닙니다. 내가 생성 된 HTML 코드를 검사하고 난 사람은 다음을 참조하십시오
<form id="form" name="form" action="/path/MyOtherAction.action" method="post" onSubmit="sendAjaxRequest();">
<table class="wwFormTable">
<tr>
<td class="tdLabel"><label for="form_libelle" class="label">Libelle:</label></td>
<td><input type="text" name="libelle" value="" id="form_libelle"/></td>
</tr>
<tr>
<td class="tdLabel"><label for="form_id" class="label">id:</label></td>
<td><input type="text" name="ide" value="" id="form_id"/></td>
</tr>
...
<td colspan="2"><div align="right"><input type="submit" id="form_0" value="Valider"/>
..
<td colspan="2"><div align="right"><input type="reset" value="Effacer"/>
..
</table>
</form>
그래서 MyOtherAction 내 sendAjaxRequest하기 전에 먼저 실행됩니다. MyOtherAction을 내 양식에서 제거하는 방법? 읽어 주셔서 감사합니다.
auteur가 클래스에 정의되어 있지 않기 때문에 컴파일되지 않는 작동을 제공해야합니다 ... 런타임 오류가 발생했다는 것을 고려하면 어떤 일이 발생했는지 알기가 어렵습니다. – Quaternion
쿼터니온 맞습니다. 실수였습니다. – Pracede
작업 예제를 만든 다음 잘라내어 붙여 넣으십시오. 시각적으로도 실패 할 것이라고 말할 수 있습니다. – Quaternion