<FORM name="formuser" enctype="multipart/form-data" method="POST">
<input type="file" name="files" >
<input type="submit" id="submit" value="提交表单" />
</FORM>
这个是我的提交页面代码
public class CallingValidator implements Validator {
public boolean supports(Class clazz) {
return CallingInfo.class.isAssignableFrom(clazz);
} public void validate(Object obj, Errors errors) {
CallingInfo info =(CallingInfo)obj;
}}
判断代码。public class CallingInfoAction extends SimpleFormController {
private String UploadFile="files";
protected ModelAndView onSubmit(HttpServletRequest req,
HttpServletResponse rep, Object cmd, BindException ex) {
ModelAndView mv = null;
return mv; } protected Object formBackingObject(HttpServletRequest request)
throws Exception {
System.out.println(new java.util.Date()+" -> "+CallingInfoAction.class.getName()+" -> formBackingObject");
String action = Tools.getString(request.getParameter("action"));
CallingInfo callinfo = new CallingInfo();
callinfo.setActionType(action);
if(action.equals("edit")){
String id =request.getParameter("id");
ClassPathXmlApplicationContext tx = new ClassPathXmlApplicationContext(
ConfigMessage.APPLICATIONCONTEXT);
DaoImpl dao = (DaoImpl) tx.getBean(ConfigMessage.BEAN);
Callingimg call = (Callingimg)dao.get(Callingimg.class, Integer.valueOf(id)); callinfo.setFiles(null);
tx.close();
}
return callinfo;
}}
逻辑层代码
<input type="file" name="files" >
<input type="submit" id="submit" value="提交表单" />
</FORM>
这个是我的提交页面代码
public class CallingValidator implements Validator {
public boolean supports(Class clazz) {
return CallingInfo.class.isAssignableFrom(clazz);
} public void validate(Object obj, Errors errors) {
CallingInfo info =(CallingInfo)obj;
}}
判断代码。public class CallingInfoAction extends SimpleFormController {
private String UploadFile="files";
protected ModelAndView onSubmit(HttpServletRequest req,
HttpServletResponse rep, Object cmd, BindException ex) {
ModelAndView mv = null;
return mv; } protected Object formBackingObject(HttpServletRequest request)
throws Exception {
System.out.println(new java.util.Date()+" -> "+CallingInfoAction.class.getName()+" -> formBackingObject");
String action = Tools.getString(request.getParameter("action"));
CallingInfo callinfo = new CallingInfo();
callinfo.setActionType(action);
if(action.equals("edit")){
String id =request.getParameter("id");
ClassPathXmlApplicationContext tx = new ClassPathXmlApplicationContext(
ConfigMessage.APPLICATIONCONTEXT);
DaoImpl dao = (DaoImpl) tx.getBean(ConfigMessage.BEAN);
Callingimg call = (Callingimg)dao.get(Callingimg.class, Integer.valueOf(id)); callinfo.setFiles(null);
tx.close();
}
return callinfo;
}}
逻辑层代码
比如啊,struts里面有个FormFile类来专门处理这个东动,
有没有出错信息?
没有任何的出错信息 以前的几个上传附件也是这样做的没有任何的问题。这次能了几天了 ,还是不能提交,不是说,不能在后面的页面得到参数,而是提交就感觉在刷新本页一样,只是输入的数据保留而已。
还有这个是spring mvc 不是struts 请大家帮忙顶 ,顶也有分的。这个问题太奇怪了。
是不是这里写错了?你有设置这个action吗?
在上传附件的时候 他会报这个错误,
Failed to convert property value of type [org.springframework.web.multipart.commons.CommonsMultipartFile] to required type [byte[]] for property files; nested exception is java.lang.IllegalArgumentException: argument type mismatch 但是我找不到这个错误 错在那里了?