1.è°è½ä»ç»ä¸ä¸strutsä¸çactionï¼
2.action与servlet的源码买进股票指标源码区别
è°è½ä»ç»ä¸ä¸strutsä¸çactionï¼
strutsçæ§å¶å¨æ:ActionServlet,RequestProcessor,è¿æå°±æ¯å ·ä½çAction
strutsæéè¦çç±»ActionServlet继æ¿äºHttpServletã
æ以说æè°çstrutsä¸è¿æ¯ä¸ä¸ªservlet.
é¦å çä¸ä¸ªwebé ç½®æ件è°è°Strutsçå¯å¨ã
è¿ä¸ªé ç½®æ件åè¯æ
æè°ActionServletå°±æ¯ä¸ä¸ªservletãå¨è¿éååå«ä½action.
ä»»ä½ä»¥.doç»æçURLé½å»ä¼è®¿é®è¿ä¸ªå«åactionçservlet.
è¿ä¸ªå«actionçservletå¨æå¡å¨è£ è½½çæ¶åä¼ä»¥æé«ä¼å 级被åå§åã
åå§åæ¶struts-config.xmlçinit-paramä¿¡æ¯ä¼è¢«å°è£ å°ä¸ä¸ªServletConfigä¸
并è°ç¨è¿ä¸ªservletçinitæ¹æ³ãå ·ä½strtusçinitæ¹æ³çå 容æ¯è¾å¤æè¿éçç¥ã
è³æ¤Strutså¯å¨åå§åå·¥ä½å®æã
ç°å¨å ·ä½è°è°strutsååºä¸ä¸ªè¯·æ±çè¿ç¨ï¼ä¹å°±æ¯servlet.serviceï¼
ä¸è¬strutså ¥é¨çæ¶åé½ç¥éstrutsæ¡æ¶3个éè¦çç±»ã
ActionServlet,Action,ActionForm.
ä½å ¶å®æä¸ä¸ªéè¦ç类被忽è§äºå°±æ¯RequestProcessorã
å®éæçåè°äºActionServlet,AcitonåActionForm.
å½ActionServletæ¥åä¸ä¸ªè¯·æ±æ¶ActionServletä¼è°ç¨è¶ ç±»æ¹æ³service()
serviceæ¥çä¼è°ç¨doGet,doPostã
ActionServletçdoGet,doPosté½ä¼è°ç¨RequestProcessorçprocess()å¤ç请æ±ã
ä½æ¯processå é¨å¾å¤æä¼è°ç¨N个processXXXX(ä¹é½æ¯RequestProcessorçæ¹æ³).
å ¶å®è¿ä¹å°±æ¯æè°Strutså¤ç请æ±çè¿ç¨äºã
å è°ä¸æ¹æ³çè°ç¨æ¬¡åº
1.processMultipart()
2.processPath()
3.processLocale()
4.processContent()
5.processNoCache()
6.processPreprocess()
7.processMapping()
8.processRoles()
9.processActionForm()
.processPopulate()
.processValidate()
.processForward()
.processInclude()
.processActionCreate()
.processActionPerform()
.processActionForward()
ä»å¤©å è°ä¸äºç®åç顺åºæµç¨7->9->->->->->
processMapping å¤ææ¯å¦åå¨æç¹å®çActionMap
processActionForm 寻æ¾æå建ä¸ä¸ªActionForm,并ä¿å
processPopulate è°ç¨ActionForm.resetç¶åå°è¡¨åæ°æ®æ¾å ¥ActionForm
processValidate è°ç¨ActionForm.validateéªè¯è¡¨å
processActionCreate å建æ寻æ¾ä¸ä¸ªAction
processActionPerform æ§è¡Actionçexecuteæ¹æ³
processActionForward æ ¹æ®Action.execut()çè¿å对象ActionForwordéå®å
action与servlet的区别
其实就是一个玩意儿!
只不过action是那些MVC框架的控制层的叫法.
--
当然,这个回答是笼统了点,但是其实就那回事.
那些MVC框架用Servlet(struts1)或者Filter(struts2)来封装了HttpServletRequest和HttpServletResponse对象,在自己的Action类中实现控制层.从对象本身来说,确实不是一个东西,但是从设计分层(架构)上看,这对于使用框架的开发者来说,这难道不是一样的道理?就是控制层!
action是业务层?那要看你这个工程项目的规模了.要是小网站,那可以把service都写在action里面.但从这个角度来说,是把service层合并到控制层去了.