-
spring mvc
查看全部 -
intercaptor对controller前后的操作
查看全部 -
springmvc结构图
查看全部 -
Spring MVC
查看全部 -
JSON
查看全部 -
JSON
查看全部 -
文件上传
查看全部 -
forward & redirect
查看全部 -
Controller
查看全部 -
import 的 model 是 “import org.springframework.ui.Model;”,而不是maven里的model类
查看全部 -
Spring MVC
查看全部 -
DispatcherServlet
查看全部 -
Maven
查看全部 -
修改中心仓库
查看全部 -
mvn -version
查看全部 -
Maven
查看全部 -
Spring MVC
查看全部 -
Spring MVC
查看全部 -
MVC 架构
查看全部 -
Front Controller
查看全部 -
虽然和教程里的运行结果一样,但是很多地方我不理解,所以下面的代码里很可能有错误的地方
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对应的上下文配置,默认为/WEB-INF/$servlet-name$-servlet.xml,下面语句改变了该默认参数 --> <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标注的类,不搜索其他标注的类 --> <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(与教程中不太一样,教程里的一些东西我没有写上去)
<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>
------------------------------------------------------------------------------------------
文件位置:
查看全部
举报