標簽的控制作用以及在springmvc中此標簽的的配置方式


我們在寫安全性較高的網站時必然會對網站的入口進行限制,

而在這其中其關鍵作用的就是網站的根目錄下WEB-INF中的web.xml中
<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

它的作用就是定制首頁,你也可能會問我想定制多個行嗎?答案是可以的

<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>

<welcome-file>myjsp.jsp</welcome-file>
</welcome-file-list>

而我現在用到的是springmvc, 用Spring MVC后,所有的request都會被dispatcher處理,於是我們則必須在web.xml中進行如下配置達到目的

<!-- SpringMVC前端控制器 -->
 <servlet>
  <servlet-name>spring-mvc</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
  <servlet-name>spring-mvc</servlet-name>
  <url-pattern>*.do</url-pattern><!-- 必須 要寫-->
 </servlet-mapping>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM