首页>代码>Spring MVC多视图配置简单demo实例,支持freemarker、velocity、jsp视图>/springmvc-freemarker/src/com/spring/action/HelloWorldAction.java
package com.spring.action;

import java.util.HashMap;
import java.util.Map;

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

/**
 * 
 * 项目名称:spring-freemarker-v1
 * 描述 :hello_jsp 表示解析jsp类型的hello页面
 * 类名称:HelloWorldAction 
 * 创建人:jl 
 * 创建时间:2016年4月15日 下午2:42:42
 */
@Controller
public class HelloWorldAction {
	
	@RequestMapping(value="/helloworld")
	public ModelAndView hello(){
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("hello.jsp");
		modelAndView.addObject("message", "Hello,SpringMvc,你好");
		return modelAndView;
	}
	
	
	@RequestMapping(value="/welcome")
	public ModelAndView helloVm(){
		ModelAndView modelAndView=new ModelAndView();
		modelAndView.setViewName("welcome.vm");
		modelAndView.addObject("message", "Hello,Velocity,你好");
		return modelAndView;
	}
	
	
	@RequestMapping(value="/free")
	public String free(Model model){
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("message", "hello world,你好!");
		model.addAttribute(result);
		return "freemarker.ftl";
	}
}
最近下载更多
天气预报  LV11 2022年12月16日
我是helloworld  LV23 2020年12月25日
caozhou  LV14 2019年3月12日
小乔醉美  LV5 2018年11月7日
leiphone  LV2 2018年11月1日
恩恩恩恩恩恩  LV1 2018年8月10日
hackboy  LV4 2018年7月27日
zwyzwyzwy  LV1 2018年6月5日
china_0221  LV41 2018年5月16日
fengxiangshe  LV15 2018年2月23日
最近浏览更多
smart123456  LV1 2023年3月15日
寒樱玉冕  LV12 2023年2月3日
天气预报  LV11 2022年12月16日
a1677596408  LV23 2022年7月1日
秦sir3067683450  LV10 2021年6月2日
vae222  LV2 2021年4月20日
cxlabc2005  LV1 2021年3月9日
kpadmin  LV1 2021年2月10日
fcy0207  LV10 2021年1月27日
我是helloworld  LV23 2020年12月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友