上面一篇寫的是配置式的控制器現在已經不推薦使用了,其實註解式控制器和它的差不多只不過
更簡潔而已!
1.還是在web.xml中進行配置dispatcherservlet
spring
org.springframework.web.servlet.dispatcherservlet
contextconfiglocation
/web-inf/classes/spring-servlet.xml
1spring/
spring-servlet.xml
<?xml version="1.0" encoding="utf-8"?>
xmlns:xsi="" xmlns:tx=""
xmlns:context=""
xmlns:mvc=""
xsi:schemalocation="
/spring-beans-3.0.xsd
/spring-tx-3.0.xsd
/spring-context-3.0.xsd
/spring-mvc-3.0.xsd">
class="org.springframework.web.servlet.view.internalresourceviewresolver">
value="org.springframework.web.servlet.view.jstlview" />
3.編寫控制器
4.編寫檢視
hello.jsp $
5.測試在瀏覽器位址列輸入
http://localhost:8080/專案名/hello
出現hello world!證明你成功了!
SpringMVC註解式開發
controller 標註為乙個控制器 萬用字元 xx 已xx結尾的url xx 已xx開頭的url xx xx前可有0到n個目錄 xx xx前必須有1個目錄 請求 如果設定請求則只能當前請求可以訪問 使用註解式開發 controller 用於標註為乙個控制器 public class firstc...
Spring MVC註解式開發
前面介紹了springmvc框架作為我們spring框架的一部分,最核心的功能就是幫助我們強化註解的使用,主要是幫助我們來管理控制層的。一 springmvc的使用 其中必須介紹的就是 註冊元件掃瞄器 那麼我們只需要在web inf的view包下建立這兩個jsp檔案 spring mvc這個框架使用...
SpringMVC之組合註解
一 restcontroller 官方文件解釋 restcontroller is a stereotype annotation that combines responsebody and controller.restcontroller註解相當於 responsebody controlle...