struct上传文件报No result defined for action action.Develope

J2EE 码拜 8年前 (2016-03-18) 1108次浏览
jar包都导入进去了。
下面是jsp代码
<s:form action=”uploadFileAction” method=”post” enctype=”multipart/form-data”>
<s:file name=”txt”></s:file>
<s:submit></s:submit>
</s:form>
下面是action内的内容
private File txt;
private String txtContentType;
private String txtFileName;
public String uploadFile(){
System.out.println(“sssssss”);
System.out.println(txt);
System.out.println(txtContentType);
System.out.println(txtFileName);
return SUCCESS;
}
下面是struct.xml的内容
<action name=”uploadFileAction” class=”action.DeveloperAction” method=”uploadFile”>
<result name=”success”>login.jsp</result>
<!–  <result name=”input”>error.jsp</result> –>
</action>
本人把输出错误时的注释了,加上这个治标不治本。
问题描述:
三个变量名写了get和set方法,当本人没有选中文件直接提交时能走到action,并打印了三个值为空,当有选择文件时,debug模式下,在setFileName方法结束后直接跳到了这个错误页面,没有进入uploadFile函数中!网上查了好久没有找到错误,下面是本人action的全部成员,网上说重名什么的,本人觉得和本人的问题没有关系。
private String userName;
private String password;
private DBOperation dbOperation;
private String fileNames;
private HttpServletRequest request;
private int pageSize=10;
private int page = 0;
private String result;
private File txt;
private String txtContentType;
private String txtFileName;
private boolean unicodeFile;
解决方案

20

假如进了action而没有进入方法那有可能是struts 走了默认方法excute…假如连action都没进去的话可以看下页面的form请求路径是不是需要加一个斜杠/

20

setFileName,要知道你那个是txtFileName,可能真是重名问题

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明struct上传文件报No result defined for action action.Develope
喜欢 (0)
[1034331897@qq.com]
分享 (0)