Code:
1 Public classRandomactionextendspageaction {2 3 /**Random Extraction **/4 PrivateIrandomservice Randomservice;5 6 /**responsible Civilian police **/7 PrivateIsczrmjservice Sczrmjservice;8 9 /**Enterprise Basic Information **/Ten PrivateIqyjbxxservice Qyjbxxservice; One A Privateuser user; - - //Private Map randommap=new HashMap (); the - Public voidSetrandomservice (Irandomservice randomservice) { - This. Randomservice =Randomservice; - } + - Public voidSetsczrmjservice (Isczrmjservice sczrmjservice) { + This. Sczrmjservice =Sczrmjservice; A } at - Public voidSetqyjbxxservice (Iqyjbxxservice qyjbxxservice) { - This. Qyjbxxservice =Qyjbxxservice; - } - - /** in * Get a list of randomly selected responsible police officers - * @return to */ + PublicString queryrandomzrmjlist () { - //randommap.put ("Zrmjlist", This.getrandomzrmjlist ()); the //randommap.put ("Qyjbxxlist", This.getrandomqyjbxxlist ()); * return"Success"; $ }Panax Notoginseng - /** the * Get a list of randomly selected responsible police officers + * @return A */ the@SuppressWarnings ("Unchecked") + PublicList<zrmjfghy>getrandomzrmjlist () { -Actioncontext CTX =Actioncontext.getcontext (); $HttpServletRequest request =(HttpServletRequest) ctx.get (servletactioncontext.http_request); $HttpSession session=request.getsession (); -User=(User) Session.getattribute (constants.userkey); -Integer _deptid=User.getdepartid (); theZrmjfghy _getzrmj=NewZrmjfghy (); - if(_deptid==2){Wuyi_GETZRMJ.SETGXDWBM (""); the}Else{ -_GETZRMJ.SETGXDWBM (_deptid+ ""); Wu } - returnsczrmjservice.getrandomzrmjlist (_GETZRMJ); About } $ - /** - * Get a list of random businesses - * @return A */ +@SuppressWarnings ("Unchecked") the PublicList<qyjbxx>getrandomqyjbxxlist () { -Actioncontext CTX =Actioncontext.getcontext (); $HttpServletRequest request =(HttpServletRequest) ctx.get (servletactioncontext.http_request); theHttpSession session=request.getsession (); theUser=(User) Session.getattribute (constants.userkey); theString _deptcode=User.getdepartcode (); theQyjbxx _getqyjbxx=Newqyjbxx (); - _GETQYJBXX.SETGXDWBM (_deptcode); in returnqyjbxxservice.getlistqyjbxx (_getqyjbxx); the } the About}View Code
First, only the Queryrandomzrmjlist () method can be executed completely. No problem. After that, there is too much code in this method. are split into Getrandomzrmjlist () and Getrandomqyjbxxlist (). This is a sad death. Suddenly the program becomes slow. Browsers and MyEclipse will die. Worried about the dead. I can't find the reason why. After a few hours of struggle. In Get. The time of the set variable. Inspiration. Method before plus get seems to have a problem ... Because the STRUTS2 internal mechanism. So Getrandomzrmjlist () and getrandomqyjbxxlist () are executed as get and set. Two method names are changed to not after get and set start. The program runs completely without problems.
About get and set in STRUTS2 action.