1.springbootåjspçåºå«ï¼
springbootåjspçåºå«ï¼
ssmåspringbootçåºå«æ¯ä»ä¹?码入分时主力决策源码
åçå¦ä¸ï¼
å¨å¼åä¸çåºå«è¿æ¯åå¨çï¼è½ç¶springbootç®åäºé ç½®ï¼ä½å¹¶ä¸ä»£è¡¨ä¸éè¦ç¼åé ç½®æ件ï¼è¿æ¯éè¦å¨èªå¸¦çapplication.ymlæ件ä¸å»ç¼åä¸äºå 容ï¼åªä¸è¿ç¼åçæ¹å¼åå¾ç®åäºï¼è½ç¶ç®åäºï¼ä½æ¯åSSMæ´åçæ¹å¼è¿æäºåºå«ã
å¨ä½¿ç¨SSMå¼åçæ¶åï¼å¤æ°ä¼éæ©Jspä½ä¸ºè§å¾ï¼ä½æ¯springbootä¸æ¨è使ç¨jspï¼ä¸»æ¨çæ¯thymeleafåfreemarkerç模æ¿å¼æï¼ä¹é æäºä½¿ç¨SSMå¼åå°springbootå¼åä¹éè¦ä¸å®çå¦ä¹ ææ¬ãä¸è¿å¦æææ¡äºSSMçè¯ï¼å¦ä¹ springbootä¹æ¯æ°´å°æ¸ æï¼å¼å¸¸çç®åã
ç¸å ³ä»ç»ï¼
æºç¹å®ç»ææ¯ä¸ç§åºå«äºä¼ ç»ç»æçæ°çä¸å¡æ¨¡åï¼å®ä½¿ç¨ç»æç»å°ååç»ææºå°ååæ¶æ¥æ è¯ä¸ä¸ªç»æä¼è¯ï¼èä¸æ¯åä¼ ç»çç»ææå¡é£æ ·åªä½¿ç¨ç»æç»å°åæ¥æ è¯ä¸ä¸ªç»æä¼è¯ã
SSMä¿çäºä¼ ç»PIM-SM模å¼ä¸ç主æºæ¾ç¤ºå å ¥ç»æç»çé«ææ§ï¼ä½æ¯è·³è¿äºPIM-SM模å¼ä¸çå ±äº«æ åRP(RendezvousPointï¼éåç¹)è§ç¨ãå¨ä¼ ç»PIM-SM模å¼ä¸ï¼å ±äº«æ åRPè§ç¨ä½¿ç¨(*ï¼G)ç»å¯¹æ¥è¡¨ç¤ºä¸ä¸ªç»æä¼è¯ï¼å ¶ä¸(G)表示ä¸ä¸ªç¹å®çIPç»æç»ï¼è(*)表示ååç»æç»Gçä»»ä½ä¸ä¸ªæºã
SSMç´æ¥å»ºç«ç±(Sï¼G)æ è¯çä¸ä¸ªç»ææçè·¯å¾æ (SPTï¼ShortestPathTree)ï¼å ¶ä¸(G)表示ä¸ä¸ªç¹å®çIPç»æç»å°åï¼è(S)表示ååç»æç»Gçç¹å®æºçIPå°åã
SSMçä¸ä¸ª(Sï¼G)对ä¹è¢«ç§°ä¸ºä¸ä¸ªé¢é(Channel)ï¼ä»¥åºåä¼ ç»PIM-SMç»æä¸çä»»ææºç»æç»ãç±äºASMæ¯æç¹å°å¤ç¹åå¤ç¹å°å¤ç¹ä¸¤ç§ç»æä¸å¡æ¨¡å¼ï¼å æ¤æºçåç°è¿ç¨æ¯ASMå¤ææ§çåå ã
ä¾å¦å¨PIM-SM模å¼ä¸ï¼ç¨æ·ç¹å»æµè§å¨ä¸çç»æå 容ï¼æ¥æ¶ç«¯è®¾å¤åªè¢«éç¥å°ç»æç»çå 容ï¼è没æ被éç¥å°ç»ææºçä¿¡æ¯ãèå¨SSM模å¼ä¸ï¼ç¨æ·ç«¯å°åæ¶æ¥æ¶å°ç»ææºåç»æç»ä¿¡æ¯ã
å æ¤ï¼SSMç¹å«éåäºç¹å°å¤ç¹çç»ææå¡ï¼ä¾å¦ç½ç»å¨±ä¹é¢éãç½ç»æ°é»é¢éãç½ç»ä½è²é¢éçä¸å¡ï¼ä½å¦æè¦æ±å¤ç¹å°å¤ç¹ç»ææå¡åéè¦ASM模å¼ã
第äºç« ï¼SpringBootä¸JSPé´ä¸å¯æè¿°çç§å¯
springbootå é¨å¯¹jspçæ¯æ并ä¸æ¯ç¹å«çæ³ï¼èspringbootæ¨èçè§å¾æ¯Thymeleafï¼å¯¹äºjavaå¼å人åæ¥è¯´è¿æ¯å¤§å¤æ°äººåå欢使ç¨jspï¼æ¥ä¸æ¥æ们æ¥è®²è§£ä¸springbootæ¯å¦ä½æ¯æjspçã
æ´åspringbootweb项ç®æ¯æjspä½ä¸ºè§å¾è¾åºã
æå®å°å¹´å¨å客æ´çåºæ¥äºSpringBootãApiBootãSpringCloudçæç« æ±æ»ãSpringBootåºç¡æç¨ä¸é¢ãï¼ãSpringCloudåºç¡æç¨ä¸é¢ãï¼ãApiBootç»ä»¶ä½¿ç¨ä¸é¢ã
æ们使ç¨IntelliJIDEAå·¥å ·æ¥æ建项ç®ï¼é¦å æ们éè¦å建ä¸ä¸ªspringboot项ç®ï¼å¦ä¸å¾1æ示.
ç¹å»Nextåè¾å ¥ä¸äºé¡¹ç®çåºæ¬åæ°ï¼å åï¼å·¥ç¨åï¼æå å½¢å¼ï¼mavenå½¢å¼æ建çï¼ï¼å¦ä¸å¾2æ示ï¼
ç¹å»Nextåéæ©æ们é¢å å å ¥å°å·¥ç¨çspringbootå ç½®çjarå ç»ä»¶ï¼æ们è¿ééæ©ä¸ä¸ªwebç»ä»¶ãå¦ä¸å¾3æ示ï¼
ç¹å»Nextè¾å ¥é¡¹ç®å称ååºå®¶Finishæ¢å¯ä»¥å®æäºé¡¹ç®çæ建ãæ°æ建ç项ç®ç®å½ç»æå¦ä¸å¾4æ示ï¼
å¯ä»¥çå°ä¸å¾ä¸æ¯æ们lessonOne项ç®ä¸å¤åºæ¥äºä¸ä¸ªç±»æ件,ServletInitlalizerï¼æå¼è¯¥ç±»æ们ä¸é¾åç°å®ç»§æ¿äºSpringBootServletInitializerè¿ä¸ªç¶ç±»ï¼èSpringBootServletInitializerè¿ä¸ªç±»æ¯springbootæä¾çwebç¨åºåå§åçå ¥å£ï¼å½æ们使ç¨å¤é¨å®¹å¨ï¼åææç« è®²è§£ä½¿ç¨å¤é¨tomcatå¦ä½è¿è¡é¡¹ç®ï¼è¿è¡é¡¹ç®æ¶ä¼èªå¨å 载并ä¸è£ é ã
å®ç°äºSpringBootServletInitializerçåç±»éè¦éåä¸ä¸ªconfigureæ¹æ³ï¼æ¹æ³å èªå¨æ ¹æ®LessontwoApplication.classçç±»åå建ä¸ä¸ªSpringApplicationBuilder交ä»ç»springbootæ¡æ¶æ¥å®æåå§åè¿è¡é ç½®ã
æ们æå¼pom.xmlï¼mavené ç½®æ件ï¼å¯ä»¥çå°æ们ä¹åæ建项ç®æ¶å·²ç»æ·»å äºweb模åï¼èspringbootç»æ们èªå¨æ·»å äºspring-boot-starter-tomcaté ç½®å¼å ¥ãspringbootå é¨éæäºtomcatç»ä»¶ï¼è¿éæ们就ä¸éè¦éå¤å¼å ¥tomcatç»ä»¶ã
æ们å æ¥æ·»å jspçmavenæ¯æï¼å¦ä¸å¾4æ示ï¼
æ们è¿éè¦å¼å ¥jsp对servlet容å¨çæ¯æ,å¦ä¸å¾5æ示ï¼
é¤äºä¸é¢çjsp,servletæ¯æ以å¤ï¼å¦æä½ è¿éè¦å¨jsp页é¢ä½¿ç¨jstlæ ç¾æ¥å¤ççé¢é»è¾ï¼é£ä¹éè¦å¼å ¥jstlmavenï¼å¦ä¸å¾6æ示ï¼
ä¸é¢é 置就æ¯æ们æ¬ç« éè¦çå ¨é¨é ç½®ï¼é£ä¹æ们å æ¥å°è¯è¿è¡ä¸é¡¹ç®æ¯å¦å·²ç»å¯ä»¥æ£å¸¸è¿è¡ãè¿é项ç®è¿è¡ä¹å¯ä»¥ä½¿ç¨IntelliJIDEAå·¥å ·æä¾çç»ä»¶æ¥å®æï¼å¦ä¸å¾7æ示,ï¼
ï¼æ³¨æï¼å¦æä½ å·²ç»å¼å¯äºå¦å¤ä¸ä¸ªspringboot项ç®è¯·å å ³éï¼å 为springbootå ç½®ç端å£å·é½æ¯è¿æ ·ä¼å¼èµ·å²çªï¼
ç¹å»ç»¿è²ä¸è§å·å³å¯å¼å§è¿è¡é¡¹ç®ï¼æ们å æ¥å°è¯ä¸ç¹å»åççæ§å¶å°è¾å ¥çæ¥å¿ä¿¡æ¯ãå¯ä»¥çå°é¡¹ç®å·²ç»æ£å¸¸è¿è¡äºï¼å³ä¸è§ç绿è²ä¸è§å·ä¹åæäºéå¯çæé®ï¼å¦ä¸å¾8æ示ï¼
项ç®è¿è¡å¦å¾9æ示ï¼
å¯ä»¥çå°é¡¹ç®å·²ç»æ£å¸¸è¿è¡ï¼ä½æ¯æ们ç°å¨è¿æ²¡æé ç½®ï¼å建JSPæ件ï¼æ们æ¥ä¸æ¥å¼å§é ç½®ï¼å建JSPã
å¦ææ¯ä½¿ç¨è¿eclipseå·¥å ·ç人è¯å®ç¥éjspæ件ä¹åæ¯å¨/webapp/WEB-INF/jspç®å½ä¸ï¼é£ä¹æ们ä¹æ²¿ç¨eclipseçé£æ ¼ã
1.å¨mainç®å½ä¸å建webappæ件夹
2.å¨webappä¸å建jspæ件夹å¦ä¸å¾æ示ï¼
3.ä¿®æ¹application.propertiesæ件让springmvcæ¯æè§å¾ç跳转ç®å½æå为/main/webapp/jspï¼é ç½®å¦ä¸å¾æ示ï¼
æ们å¨webapps/jspç®å½ä¸å建ä¸ä¸ªindex.jspç¨äºæµè¯æ们çé ç½®æ¯å¦å·²ç»æ¯æäºjspï¼æ°å»ºjspæ件å¦ä¸å¾æ示ï¼
ä¸é¢å·¥ä½æ们已ç»å®æäºjspçææé ç½®ï¼é£ä¹æ¥ä¸æ¥æ们éè¦é ç½®springmvcçæ§å¶å¨ï¼æ们æ°å»ºindexControllerå¦ä¸å¾æ示ï¼
å¯ä»¥çå°ä¸å¾æ们å¨IndexControlleré ç½®æ件å æ·»å äºindex()æ¹æ³é ç½®äº@RequestMapping注解æ¥æè¿°index()æ¹æ³æ¯ä¸ä¸ªå¯ä»¥è¢«springmvc管çç请æ±è§å¾ãæ们çindex()æ¹æ³è¿åå¼è¿éæ¯"index"ã
为ä»ä¹æ们è¿å"index"ï¼è¿è®°å¾ä¸è¿°æ¥éª¤ä¸é ç½®çapplication.propertiesæ件çspringmvc请æ±åç¼ä»¥ååç¼ï¼é£ä¹å½æ们访é®/indexæ¶springmvcå°±ä¼å»æ¾/webapp/WEB-INF/jsp/index.jspæ件ã
éå¯é¡¹ç®æ们å°è¯è®¿é®.0.0.1:/indexï¼å¯ä»¥çå°å¦ä¸å¾çææï¼è¯æå·²ç»å®æäºspringbootä¸jspçæ´åï¼
ä¸è¿°ä¾¿æ¯æ们æ¬ç« çå ¨é¨å 容ï¼æ¬ç« 主è¦æ¯è®²è§£äºspringbootéæjspä½ä¸ºæ¸²æè§å¾ï¼ç»åspringmvcæ¥è½¬å请æ±ã
æ¬ç« å 容已ç»ä¸ä¼ å°ç äºï¼
SpringBooté å¥æºç å°åï¼
SpringCloudé å¥æºç å°åï¼
SpringBootç¸å ³ç³»åæç« è¯·è®¿é®ï¼ç®å½ï¼SpringBootå¦ä¹ ç®å½
QueryDSLç¸å ³ç³»åæç« è¯·è®¿é®ï¼QueryDSLéç¨æ¥è¯¢æ¡æ¶å¦ä¹ ç®å½
SpringDataJPAç¸å ³ç³»åæç« è¯·è®¿é®ï¼ç®å½ï¼SpringDataJPAå¦ä¹ ç®å½
SpringBootç¸å ³æç« è¯·è®¿é®ï¼ç®å½ï¼SpringBootå¦ä¹ ç®å½ï¼æè°¢é 读ï¼
ç¥è¯æç-æå®å°å¹´
jspåspringbootåªä¸ªç®åspringbootç®åãspringbootååçå¦ä¹ ç®åãè½»é级以å容ææ©å±çä¼ç¹ï¼æ为äºè¬ååå±çå¿«éåºç¨å¼åé¢åçé¢å¯¼è ï¼å¯ä»¥æ¿ä»£jspæ¶æä¸çå½é åæ¯æå®è·µï¼å æ¤springbootç®åã