SoringMVC-02-使用注解开发
2021-02-08 22:15
阅读:824
标签:pattern value not cat 装备 pac 容器 resource dispatch
3、使用注解开发
1、还是配置web.xml
直接可以拿去用
springmvc org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:springmvc-servlet.xml 1 springmvc /
2、在Spring配置文件中指定要扫描的包和使用注解开发
可以直接拿来用,作用写在注释中
3、用到的注解
- controller
指定当前类是一个controller,控制器,如果被扫描的话,则会自动装备在Spring中
- resource,错误:是RequestMapping
也就是我们访问的 url 地址拼接
@Controller
public class helloAnno {
@RequestMapping("/h1")
public String hello(Model model) {
model.addAttribute("msg", "hello,SpringMVC!!");
return "test";
}
}
- 方法的返回值代表的是之前的setName中要被拼接的路径
4、遇到的错误
又遇到jar包没有导入项目的lib目录的情况,而出现404错误
SoringMVC-02-使用注解开发
标签:pattern value not cat 装备 pac 容器 resource dispatch
原文地址:https://www.cnblogs.com/bingstudy/p/13065280.html
上一篇:脚本安装Apache与工作模式
下一篇:CSS定位
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:SoringMVC-02-使用注解开发
文章链接:http://soscw.com/index.php/essay/52823.html
文章标题:SoringMVC-02-使用注解开发
文章链接:http://soscw.com/index.php/essay/52823.html
评论
亲,登录后才可以留言!