竹笋

首页 » 问答 » 灌水 » SpringMVC入门实例
TUhjnbcbe - 2023/3/26 20:06:00
白癜风有什么办法治疗 http://news.39.net/bjzkhbzy/180204/6043532.html

一、SpringMVC的HellowWord示例

非注解方式,根据beanname来查找Controller

(1)pom.xml文件配置

除了springmvc的依赖,由于用到了jstl,所以新增了jstl的依赖,用的是jetty启动项目

dependenciesdependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.11/versionscopetest/scope/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-webmvc/artifactIdversion5.1.4.RELEASE/version/dependency

dependencygroupIdjavax.servlet/groupIdartifactIdjavax.servlet-api/artifactIdversion4.0.1/versionscopeprovided/scope/dependencydependencygroupIdjavax.servlet/groupIdartifactIdjstl/artifactIdversion1.2/version/dependency/dependenciesbuildfinalNameSpringmvcDemo/finalNamepluginsplugingroupIdorg.eclipse.jetty/groupIdartifactIdjetty-maven-plugin/artifactIdversion9.4.3.v/version/plugin/plugins/build

(2)web.xml配置

servletservlet-namespringmvc/servlet-nameservlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class/servletservlet-mappingservlet-namespringmvc/servlet-nameurl-pattern//url-pattern/servlet-mapping

(3)在web-info下面创建springmvc-servlet.xml文件,并把controll类注入spring容器

beanname=/hellclass=

1
查看完整版本: SpringMVC入门实例