首页>代码>基于spring mvc+maven的demo实例>/SpringMVC/src/main/java/com/tuletech/web/controller/Hello.java
package com.tuletech.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class Hello {

	/**
	 * @函数功能:测试1[正常访问]
	 * @备注:用http://xxxxx/hello.do访问,输出"hello.do被执行"
	 * @创建人:任齐
	 * @return void    
	 * @throws
	 */
	@RequestMapping(value="hello.do")
    public void hello(){
        System.out.println("hello.do被执行"); 
    }
	
	/**
	 * @函数功能:测试2[跳转界面]
	 * @备注:用http://xxxxx/index.do访问,输出"index被访问",并返回/WEB-INF/views/index.jsp
	 * @创建人:任齐
	 * @return void    
	 * @throws
	 */
	@RequestMapping(value="/index")  
    public String index(){
		System.out.println("index被访问");
		return "index";
    }
	
	/**
	 * @函数功能:测试3[获取参数]
	 * @备注:用http://xxxxx/get/admin访问,输出"username:admin",并返回/WEB-INF/views/index.jsp
	 * @创建人:任齐
	 * @return void    
	 * @throws
	 */
	@RequestMapping(value="/get/{username}")  
    public String get(@PathVariable String username){
		System.out.println("username:" + username);
		return "index";
    }
	
	/**
	 * @函数功能:测试传参
	 * @备注:http://xxxxx/order/add.do?id=12&date1=2013-10-12
	 * @参数: @param request
	 * @参数: @param id
	 * @参数: @param date
	 * @创建人:任齐
	 * @return void    
	 */
	@RequestMapping(value = "/order/add", method = RequestMethod.GET)
	public void juint(
			HttpServletRequest request,
			@RequestParam int id,
			@RequestParam("date1") String date){
		System.out.println("id:" + id);
		System.out.println("date:" + date);
		request.setAttribute("msg", "id="+id+",date="+date);
	}
}
最近下载更多
lvhongquan  LV11 2022年7月10日
a1677596408  LV23 2022年7月1日
zhijian992714  LV6 2022年2月17日
admin7777  LV14 2021年8月19日
remedy  LV1 2021年6月17日
杜老师  LV1 2021年5月12日
aaaahao  LV13 2021年3月20日
erwesdfe  LV2 2021年3月2日
wx1992926  LV2 2021年1月22日
lyws1986  LV17 2020年7月19日
最近浏览更多
张真狗  LV9 2023年5月22日
花落亦知秋 2023年5月22日
暂无贡献等级
2237851964  LV1 2023年2月26日
LITIANYU084414  LV11 2023年1月1日
南山难  LV4 2023年1月1日
43093307  LV4 2022年12月16日
lvhongquan  LV11 2022年7月10日
tomcat_test  LV2 2022年7月6日
a1677596408  LV23 2022年7月1日
zhijian992714  LV6 2022年2月17日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友