Java 之 一天快速入门--SpringMVC快速入门(1)SpringMVC介绍、SpringMVC入门创建工程,SpringMVC执行流程

${ msg }

4、完善HelloControll

在这里插入图片描述

package com.itzheng.springmvc.controller;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class HelloControll {

@RequestMapping(“hello”)

public ModelAndView hello() {

System.out.println(“hello springmvc…”);

ModelAndView mav = new ModelAndView();

//设置模型数据,用于传递到JSP

mav.addObject(“msg”, “hello springmvc…”);

//设置视图名字,用于响应用户

mav.setViewName(“/jsp/hello.jsp”);

return mav;

}

}

5、配置spring相关的配置文件

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

<?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:p=“http://www.springframework.org/schema/p”

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-4.0.xsd

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd

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

<context:component-scan base-package=“com.itzheng.springmvc.controller” />

6、在web.xml当中配置前端控制器

在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>

01-springmvc

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springmvc.xml

springmvc

*.action

7、运行项目

在这里插入图片描述

访问项目

http://localhost:8080/01-springmvc/hello.action

在这里插入图片描述

三、SpringMVC执行流程


在这里插入图片描述

| | |

| — | — |

| SpringMVC快速入门(1)SpringMVC介绍、SpringMVC入门创建工程,SpringMVC执行流程 | |

| SpringMVC快速入门(2)商品列表的加载 | |

| SpringMVC快速入门(3)默认组件加载 | |

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

在这里插入图片描述

在这里插入图片描述

]( ) | |

| SpringMVC快速入门(2)商品列表的加载 | |

| SpringMVC快速入门(3)默认组件加载 | |

总结

这个月马上就又要过去了,还在找工作的小伙伴要做好准备了,小编整理了大厂java程序员面试涉及到的绝大部分面试题及答案,希望能帮助到大家

[外链图片转存中…(img-6rm8k87S-1718732874404)]

[外链图片转存中…(img-fcmBFMQ9-1718732874404)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值