I have a <s:file>
tag inside the form which generates a HTML <input type="file">
. When I submit the form via form submission (e.g. submit button, etc.) everything works fine in the action method. However, when I change my code to:
$.ajax({
url: "actionClass!actionMethodA.action",
type: "POST",
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('Error ' + textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
},
data: $(form).serialize(),
success: function(data) {
...
}
});
In the backend, the file
field is always null
.
The file field is defined in the action class as follow (with setter and getter):
private File impFileUrl;
Is it because now the form is serialized so that the file field can no longer be set properly in the backend?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…