|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
微软什么都提供了。你可以试想一下,如果你是新手,你是希望你点一下按钮程序就能运行那,还是想自己一点一点的组织结构,然后打包发部,调错再打包......
这篇博客我们深切Struts框架实行部分源码,从ActionServlet的process函数入手下手,看一下其内涵的实行历程。
流程图
以下游程图展现的是ActionServlet和RequestProcessor两个类用到的函数,如RequestProcessor挪用的别的类的函数不再申明。
函数申明
我们选择几个主要的函数申明,别的函数则复杂申明一下便可。
ActionServlet
process- /***<p>Performthestandardrequestprocessingforthisrequest,andcreate*thecorrespondingresponse.</p>**@paramrequestTheservletrequestweareprocessing*@paramresponseTheservletresponsewearecreating**@exceptionIOExceptionifaninput/outputerroroccurs*@exceptionServletExceptionifaservletexceptionisthrown*/protectedvoidprocess(HttpServletRequestrequest,HttpServletResponseresponse)throwsIOException,ServletException{ModuleUtils.getInstance().selectModule(request,getServletContext());ModuleConfigconfig=getModuleConfig(request);
- RequestProcessorprocessor=getProcessorForModule(config);if(processor==null){processor=getRequestProcessor(config);}processor.process(request,response);}}
复制代码 在调试时起首进进这个函数(Tomcat启动终了,发生哀求后),这个函数的感化是猎取加载阶段发生的Module对象,发生struts逻辑处置的次要对象RequestProcessor。
RequestProcessor
process- /***<p>Processan<code>HttpServletRequest</code>andcreatethe*corresponding<code>HttpServletResponse</code>ordispatch
- *toanotherresource.</p>**@paramrequestTheservletrequestweareprocessing*@paramresponseTheservletresponsewearecreating**@exceptionIOExceptionifaninput/outputerroroccurs*@exceptionServletExceptionifaprocessingexceptionoccurs*/publicvoidprocess(HttpServletRequestrequest,
- HttpServletResponseresponse)throwsIOException,ServletException{
- //Wrapmultipartrequestswithaspecialwrapperrequest=processMultipart(request);//IdentifythepathcomponentwewillusetoselectamappingStringpath=processPath(request,response);if(path==null){return;
- }if(log.isDebugEnabled()){log.debug("Processinga"+request.getMethod()+"forpath"+path+"");}//SelectaLocaleforthecurrentuserifrequested
- processLocale(request,response);//Setthecontenttypeandno-cachingheadersifrequestedprocessContent(request,response);processNoCache(request,response);//Generalpurposepreprocessinghookif(!processPreprocess(request,response)){return;}this.processCachedMessages(request,response);//IdentifythemappingforthisrequestActionMappingmapping=processMapping(request,response,path);if(mapping==null){return;
- }//Checkforanyrolerequiredtoperformthisactionif(!processRoles(request,response,mapping)){return;}//ProcessanyActionFormbeanrelatedtothisrequestActionFormform=processActionForm(request,response,mapping);processPopulate(request,response,form,mapping);//ValidateanyfieldsoftheActionFormbean,ifapplicabletry{if(!processValidate(request,response,form,mapping)){return;}}catch
- (InvalidCancelExceptione){ActionForwardforward=processException(request,response,e,form,mapping);processForwardConfig(request,response,forward);
- return;}catch(IOExceptione){throwe;}catch(ServletExceptione){throwe;}//Processaforwardorincludespecifiedbythismappingif(!processForward(request,response,mapping)){return;}if(!processInclude(request,response,mapping)){return;}//CreateoracquiretheActioninstancetoprocessthisrequest
- Actionaction=processActionCreate(request,response,mapping);if(action==null)
- {return;}//CalltheActioninstanceitselfActionForward
- forward=processActionPerform(request,response,
- action,form,mapping);//ProcessthereturnedActionForwardinstance
- processForwardConfig(request,response,forward);}
复制代码 <p>
市场分额,java比asp高一点,因为C#是仿照java开发的,所以哦C#能做的java都能做到,但是java能做的,C#不一定都能做到。毕竟是抄袭吗。 |
|