1. 程式人生 > >Spring MVC學習(二)

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檔案加上一段程式碼

執行後