@GetMapping失效解决方案在SSM框架中,可以使用callout来减少开发工作量,通过了解每个callout的作用和底层实现机制来方便分析问题。 如果最近禁用了@GetMapping,将总结解决方法。
原因分析https://www.Jian Shu.com/p/69 e 9f9 ed 5b 36详细分析了@GetMapping失效的原因。 在这里不重复。
解决方法1、在配置xml文件中添加以下内容。
mvc:annotation-driven/2,为了避免在添加编号说明驱动后出现编译问题,必须在xml配置文件的beans中添加以下属性:
将赋值条目添加到xmlns : MVC=' http://www.spring framework.org/schema/MVC '和xsi:schemaLocation :
在修改3358 www.spring framework.org/schema/MVC http://www.spring framework.org/schema/MVC/spring-MVC-4.3.xsd之后
? XML版本=' 1.0 '编码=' utf-8 '? beans xmlns=' http://www.spring framework.org/schema/beans ' xmlns 3360 MVC=' http://www.spring framework.org/方案XML方案-实例' xmlns : context=' http://www.spring framework.org /方案/context ' xsi :方案定位方案/beans/spring-beans-4.3.xsd 3358 www.spring framework.org /方案/方案MVC/spring-MVC-4.3.xsd 33535 context http://www.spring framework.org/schema/chema -指定要扫描的软件包--- context : component-scan base-package=' ' -定义视图解析器--bean id=' view resolver ' class=' org.spring framework.web.servlet.view.internalresourceviewresolver -设置后缀--property name=' suffix ' value='.JSP '/bean/bean验证1,测试代码
@ controller @ request mapping (value='/hello ' ) publicclassfirstcontroller ) @ get mapping (value='/3 ' ) public串列modelmodel(throwsexception(/向模型对象添加数据model.addattribute('msg,' )是我的第二个Spring MVC程序。 //视图页面返回' first '; ) 2、测试结果