一个简单的springmvc程序

2025-05-22 12:39:14

1、@Controller@RequestMapping("/hello")这就是传说中的spring。controller是一个顶层的结构requestMapping是一个映射的地址下图是:HelloController.java代码

一个简单的springmvc程序

3、<?xml version="1.0" encoding="UTF-8"?>稆糨孝汶;<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <context:component-scan base-package="Com.spring" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean></beans>beans是头文件context是包文件bean是路径property是在/WEB-INF/jsp/之下的jsp文件

一个简单的springmvc程序

5、如果我们的代码没有错,就可以起动项目,如果在下面console中没有报错,说明我们的代码是没有什么问题的,就可以在访问路径中修改一下。@RequestMapping("/hello")http://localhost:8080/HelloWeb/hello

一个简单的springmvc程序
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢