首页>代码>Spring MVC基于注解配置入门教程及其代码实例>/spring-mvc/src/main/java/com/controller/IndexController.java
package com.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

@Controller
@RequestMapping(value="/controller")
public class IndexController {
	
	@RequestMapping(value = "/method1") 
	public ModelAndView method1(HttpServletRequest request,
			HttpServletResponse respnose) throws ServletException, IOException {
		Map<String,String> model = new HashMap<String,String>();
		model.put("message", "你调用的是方法1");
		return new ModelAndView("index", "model", model);
	}
	
	@RequestMapping(value = "/method2") 
	public ModelAndView method2(HttpServletRequest request,
			HttpServletResponse respnose) throws ServletException, IOException {
		Map<String,String> model = new HashMap<String,String>();
		model.put("message", "你调用的是方法2");
		return new ModelAndView("index", "model", model);
	}
}
最近下载更多
zywzywzyw1  LV17 2019年8月6日
1004864954  LV5 2019年6月19日
云栈拓扑  LV1 2018年5月12日
一叶12224  LV4 2017年10月8日
522725190  LV2 2016年3月18日
ybbghdiu  LV27 2014年11月29日
djbjinbao  LV1 2014年8月19日
tony_328427685  LV1 2014年8月14日
wgtgt  LV24 2014年8月12日
sottas  LV17 2014年6月20日
最近浏览更多
121516  LV3 2022年7月26日
866521  LV2 2020年10月20日
rescuer023  LV1 2020年6月23日
jessia  LV4 2020年5月19日
xk9587  LV16 2020年4月9日
whj258  LV10 2020年4月3日
songchuanbin 2020年3月3日
暂无贡献等级
黄小胡  LV1 2019年11月11日
mini devil  LV6 2019年11月2日
fangg666 2019年8月8日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友