-
spring mvc
查看全部 -
intercaptor對(duì)controller前后的操作
查看全部 -
springmvc結(jié)構(gòu)圖
查看全部 -
Spring MVC
查看全部 -
JSON
查看全部 -
JSON
查看全部 -
文件上傳
查看全部 -
forward & redirect
查看全部 -
Controller
查看全部 -
import 的 model 是 “import org.springframework.ui.Model;”,而不是maven里的model類
查看全部 -
Spring MVC
查看全部 -
DispatcherServlet
查看全部 -
Maven
查看全部 -
修改中心倉(cāng)庫(kù)
查看全部 -
mvn?-version
查看全部 -
Maven
查看全部 -
Spring MVC
查看全部 -
Spring MVC
查看全部 -
MVC 架構(gòu)
查看全部 -
Front Controller
查看全部 -
雖然和教程里的運(yùn)行結(jié)果一樣,但是很多地方我不理解,所以下面的代碼里很可能有錯(cuò)誤的地方
web.xml
<!DOCTYPE?web-app?PUBLIC ?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN" ?"http://java.sun.com/dtd/web-app_2_3.dtd"?> <web-app> ??<display-name>Archetype?Created?Web?Application</display-name> ?? ??<servlet> ???<servlet-name>mvc-dispatcher</servlet-name> ???<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> ???<!--DispatcherServlet對(duì)應(yīng)的上下文配置,默認(rèn)為/WEB-INF/$servlet-name$-servlet.xml,下面語(yǔ)句改變了該默認(rèn)參數(shù) ???--> ???<init-param> ???<param-name>contextConfigLocation</param-name> ???<param-value>/WEB-INF/configs/spring/mvc-dispatcher-servlet.xml</param-value> ???</init-param> ???<load-on-startup>1</load-on-startup> ??</servlet> ??<servlet-mapping> ??<servlet-name>mvc-dispatcher</servlet-name> ??<url-pattern>/</url-pattern> ??</servlet-mapping> ?? </web-app>
------------------------------------------------------------------------------------------
mvc-dispatcher-servlet
<?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config/> <!--?讓DispatcherServelt上下文只搜索@Controller標(biāo)注的類,不搜索其他標(biāo)注的類?--> <context:component-scan?base-package="com.imooc.mvcdemo.controller"?use-default-filters="false"> <context:include-filter?type="annotation"?expression="org.springframework.stereotype.Controller"/> </context:component-scan> <mvc:annotation-driven?/> <!--?viewResolver?--> <bean?class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property?name="ViewClass"?value="org.springframework.web.servlet.view.JstlView"/> <property?name="prefix"?value="/WEB-INF/jsps/"?/> <property?name="suffix"?value=".jsp"/> </bean> </beans>
---------------------------------------------------------------------------------------------
pom.xml(與教程中不太一樣,教程里的一些東西我沒(méi)有寫上去)
<project?xmlns="http://maven.apache.org/POM/4.0.0"?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ??xsi:schemaLocation="http://maven.apache.org/POM/4.0.0?http://maven.apache.org/maven-v4_0_0.xsd"> ??<modelVersion>4.0.0</modelVersion> ??<groupId>com.how2java</groupId> ??<artifactId>springmvc2021071501</artifactId> ??<version>0.0.1-SNAPSHOT</version> ??<name>springmvc2021071501?Maven?Webapp</name> ??<url>http://maven.apache.org</url> ?? ??<dependencyManagement> ??????<dependencies> ??????????<dependency> ??????????<groupId>org.springframework</groupId> ??????????<artifactId>spring-framework-bom</artifactId> ??????????<version>${spring.version}</version> ??????????<type>pom</type> ?????????? ??????????</dependency> ??????</dependencies> ??</dependencyManagement> ?? ??<dependencies> ????<dependency> ??????<groupId>junit</groupId> ??????<artifactId>junit</artifactId> ??????<version>3.8.1</version> ??????<scope>test</scope> ????</dependency> ????<dependency> ????????<groupId>mysql</groupId> ????????<artifactId>mysql-connector-java</artifactId> ????????<version>5.1.43</version> ????</dependency> ????<dependency> ????????<groupId>javax.servlet</groupId> ????????<artifactId>javax.servlet-api</artifactId> ????????<version>4.0.0-b07</version> ????</dependency> ????<dependency> ????????<groupId>apache-lang</groupId> ????????<artifactId>commons-lang</artifactId> ????????<version>2.1</version> ????????<type>pom.lastUpdated</type> ????</dependency> ????<dependency> ????????<groupId>org.springframework</groupId> ????????<artifactId>spring-webmvc</artifactId> ????????<version>4.3.13.RELEASE</version> ????</dependency> ????<dependency> ????????<groupId>org.eclipse.jetty</groupId> ????????<artifactId>jetty-maven-plugin</artifactId> ????????<version>9.3.0.M1</version> ????????<type>maven-plugin</type> ????</dependency> ??</dependencies> ??<build> ????<finalName>springmvc2021071501</finalName> ????<plugins> ????????<plugin> ????????????<groupId>org.eclipse.jetty</groupId> ????????????<artifactId>jetty-maven-plugin</artifactId> ????????????<version>9.3.0.M1</version> ????????</plugin> ????</plugins> ??</build> </project>
------------------------------------------------------------------------------------------
文件位置:
查看全部
舉報(bào)