脚本宝典收集整理的这篇文章主要介绍了SpringMVC_02_RequestMapping,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
类和方法都可以写@RequestMapping
也可以只在方法前@RequestMapping
知识单层和双层的区别罢了
package controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @RequestMapping("/test") //两层访问 @Controller //代表这个类被spring托管 public class ControllerTest2 { @RequestMapping("/t2") public String t2(Model model) { model.addAttribute("msg","注解MVC你好"); return "test"; } }
上面的代码访问路径 /test/t2
以上是脚本宝典为你收集整理的SpringMVC_02_RequestMapping全部内容,希望文章能够帮你解决SpringMVC_02_RequestMapping所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。