|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
但是一些大型开发或者是保密型比较高的项目都会用java,原因有2点,一:java是开源的,不怕别人留后门,偷我工具,.net就不一样了,保持微软的一向风格,源代码不公开
经由过程后面几篇博客,不晓得人人有无发明这个成绩,固然如今能够天真把持跳转了,可是Action的数目仍是对照多,怎样既能包管跳转天真,还能削减Action的数目?这就是我们这篇博客所说的DispatchAction,如其名,能够了解为“分发式Action”,利用它能够制止为每一个Action创立一个类。
我们先来看一下实例。
UserAction
DispatchAction承继的是Action,它的特性就是把之前的多个Action兼并为一个,当多个Action联系关系较年夜时,能够像如许放在一同,削减Action类的同时,也下降了保护的难度。- packagecom.tgb.drp.web.actions;
- importjava.util.Date;
- importjava.util.List;
- importjavax.servlet.http.HttpServletRequest;
- importjavax.servlet.http.HttpServletResponse;
- importorg.apache.commons.beanutils.BeanUtils;
- importorg.apache.struts.action.ActionForm;
- importorg.apache.struts.action.ActionForward;
- importorg.apache.struts.action.ActionMapping;
- importorg.apache.struts.actions.DispatchAction;
- importcom.tgb.drp.manager.UserManager;
- importcom.tgb.drp.model.User;
- importcom.tgb.drp.web.forms.UserActionForm;
- publicclassUserActionextendsDispatchAction{
- @Override
- protectedActionForwardunspecified(ActionMappingmapping,ActionFormform,
- HttpServletRequestrequest,HttpServletResponseresponse)
- throwsException{
- //挪用营业逻辑操纵
- ListuserList=UserManager.getInstance().findAllUserList();
- request.setAttribute("userlist",userList);
- returnmapping.findForward("list_success");
- }
- /**
- *用户删除
- *@parammapping
- *@paramform
- *@paramrequest
- *@paramresponse
- *@return
- *@throwsException
- */
- publicActionForwarddel(ActionMappingmapping,ActionFormform,
- HttpServletRequestrequest,HttpServletResponseresponse)
- throwsException{
- //猎取从页面表单中提交过去的值
- UserActionFormuaf=(UserActionForm)form;
- //获得必要删除的userId的汇合
- String[]userIdList=uaf.getSelectFlag();
- //挪用营业逻辑操纵
- UserManager.getInstance().deleteUsers(userIdList);
- returnmapping.findForward("del_success");
- }
- /**
- *用户增加
- *@parammapping
- *@paramform
- *@paramrequest
- *@paramresponse
- *@return
- *@throwsException
- */
- publicActionForwardadd(ActionMappingmapping,ActionFormform,
- HttpServletRequestrequest,HttpServletResponseresponse)
- throwsException{
- //猎取从页面表单中提交过去的值
- UserActionFormuaf=(UserActionForm)form;
- Useruser=newUser();
- BeanUtils.copyProperties(user,uaf);
- user.setCreateDate(newDate());
- //挪用营业逻辑操纵
- UserManager.getInstance().addUser(user);
- returnmapping.findForward("add_success");}
- /**
- *修正用户
- *@parammapping
- *@paramform
- *@paramrequest
- *@paramresponse
- *@return
- *@throwsException
- */
- publicActionForwardmodify(ActionMappingmapping,ActionFormform,
- HttpServletRequestrequest,HttpServletResponseresponse)
- throwsException{
- //猎取从页面表单中提交过去的值
- UserActionFormuaf=(UserActionForm)form;
- Useruser=newUser();
- BeanUtils.copyProperties(user,uaf);
- //挪用营业逻辑操纵
- UserManager.getInstance().modifyUser(user);
- returnmapping.findForward("modify_success");
- }
- /**
- *依据ID查询用户
- *
- *@parammapping
- *@paramform
- *@paramrequest
- *@paramresponse
- *@return
- *@throwsException
- */
- publicActionForwardfind(ActionMappingmapping,ActionFormform,
- HttpServletRequestrequest,HttpServletResponseresponse)
- throwsException{
- //猎取从页面表单中提交过去的值
- UserActionFormuaf=(UserActionForm)form;
- StringuserId=uaf.getUserId();
- //挪用营业逻辑操纵
- Useruser=UserManager.getInstance().findUserById(userId);
- //将user对象从Action传送到JSP页面
- request.setAttribute("user",user);
- returnmapping.findForward("find_success");
- }
- }
复制代码 <p>
在性能方面,在windows平台下,.net可能是占强项,要是把.net放在sun开发的操作系统上去运行呢?根本就运行不了,.net对其它操作系统的支持也很弱,性能也可能比不上java。 |
|