您当前的位置: 首页 >  ar

星夜孤帆

暂无认证

  • 1浏览

    0关注

    626博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

SpringMVC基础-06-路径变量PathVariable

星夜孤帆 发布时间:2019-04-21 13:12:11 ,浏览量:1

PathController.java
package com.monkey1024.controller;

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

/*
 *获取url中的数据
 *PathVariable
 */

@Controller
public class PathController01 {
	
	@RequestMapping("/{username}/{age}/path.do")
	public ModelAndView getPath(@PathVariable("username") String name,@PathVariable int age) throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.addObject("username", name);
		mv.addObject("age", age);
		mv.setViewName("result");
		return mv;
	}

}
result.jsp




Insert title here


姓名:${username }

年龄:${age }

 

 

关注
打赏
1636984416
查看更多评论
立即登录/注册

微信扫码登录

0.0367s