日期:2014-05-18  浏览次数:20739 次

FormFile上传的问题?急在线等
请问使用struts     的   FormFile上传的时候,
如何防止表单为空的情况下按提交按钮?

------解决方案--------------------
public class App extends Action {


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {

String username = request.getParameter( "username ");

String userpwd = request.getParameter( "userpwd ");
ActionMessages ms = new ActionMessages();
ActionMessage m = new ActionMessage( "App.username.can.not.null ");
ActionMessage m1 = new ActionMessage( "App.userpwd.can.not.null ");

if(username == null || username.equals( " "))
{



ms.add( "ms ", m);
saveErrors(request, ms);
return new ActionForward( "/index.jsp ");
}
if(userpwd == null || userpwd.equals( " "))
{
ms.add( "ms ", m1);
saveErrors(request, ms);
return new ActionForward( "/index.jsp ");


}
return new ActionForward( "/ok.jsp ");
}
}
我觉得应该在action 里面判断吧
------解决方案--------------------
上传之后,对上传的流进行处理的方法行不?

我曾经这样用过。