프레임워크/Struts2
struts2에서 jQuery로 파라메터(폼값) 넘길때 주의점
짱지
2009. 12. 17. 14:36
일반적으로 스트럿츠2에서 폼값을 넘길때
<s:form name="form1" action="form1.action" method="post">
<s:textfield name="modelDto.id"/>
</s:form>
<s:textfield name="modelDto.id"/>
</s:form>
이런식으로 한다.
이걸 jQuery의 형식으로 바꾸면..
<script>
//prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
success: showResponse, // post-submit callback
url: 'form1.action', // override for form's 'action' attribute
type: 'get',
timeout: 3000
};
// bind form using 'ajaxForm'
$('#shopInputForm').ajaxForm(options);
});
// post-submit callback
function showResponse(responseText, statusText) {
//prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
success: showResponse, // post-submit callback
url: 'form1.action', // override for form's 'action' attribute
type: 'get',
timeout: 3000
};
// bind form using 'ajaxForm'
$('#shopInputForm').ajaxForm(options);
});
// post-submit callback
function showResponse(responseText, statusText) {
//submit후 작업부분
}
</script>
<s:form id="form1">
<s:textfield name="modelDto.id"/>
</s:form>
}
</script>
<s:form id="form1">
<s:textfield name="modelDto.id"/>
</s:form>
이런식으로 된다.
하지만 이런식으로 바꾸었을때 문제점이 발생했다.
전자의 방식으로 submit을 하게되면 modelDto에 id값이 정상적으로 세팅이 되지만....
후자의 방식으로 submit을 하게되면...
어라?? modelDto에 id값이 세팅이 안된다;;
method의 type를 post로 해도 마찬가지였다.
값을 넘기는 방식에서 차이가 있어서 인식을 못하는것 같다.
이 문제에 대해서 자세히 알아보진 않았지만...
혹시 이유를 아시는분은 댓글주시면 캄사~
허접이라 이해좀;;