Erlo

SpringMVC环境搭建之Idea

2019-01-11 23:01:48 发布   440 浏览  
页面报错/反馈
收藏 点赞

SpringMVC
.. SpringMVC重要组件介绍
    1. DispacherServlet:前端控制器,接收所有请求,(如果配置/不包含jsp)
    2. HandlerMapping:解析请求格式,判断希望要执行哪个方法
    3. HandlerAdapter:负责调用具体的方法
    4. ViewResovler:视图解析器,解析结果,准备跳转的具体的视图

spring的jar包官方下载地址:

https://repo.spring.io/libs-release-local/org/springframework/spring/
环境搭建
    1.导入jar包
    2.在web.xml中配置前端控制器,若不配置,会去/web-inf/servlet.xml找

qq
org.springframework.web.servlet.DispatcherServlet


contextConfigLocation
classpath:springmvc.xml

1


qq
/

  3.src下面新建springmvc.xml
   3.1.引入命名空间
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.xsd

http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">


>



**" location="/js/">
**" location="/css/">
**" location="/imgs/">

3.2.编写控制器类

1 @Controller
2 public class Democontroller {
3 @RequestMapping("demo")
4      public String demo(){
5         return "main.jsp";
6     }
7 
8 }

 




登录查看全部

参与评论

评论留言

还没有评论留言,赶紧来抢楼吧~~

手机查看

返回顶部

给这篇文章打个标签吧~

棒极了 糟糕透顶 好文章 PHP JAVA JS 小程序 Python SEO MySql 确认