Spring MVC学习(二)

上一个项目,新建一个类

代码

package cn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class ControllerMvc{
	
	@RequestMapping(value="/zhushi.html")
	public ModelAndView index(){
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("index");   
		modelAndView.addObject("message", "hello zhushi MVC");
		return modelAndView;
	}
}

在这个xml文件加上一段代码

运行后

猜你喜欢

转载自blog.csdn.net/weixin_42717928/article/details/84193893