MyEclipse10搭建MavenSpringMVC注解JavaWeb项目

2025-05-26 12:55:44

1、创建一个maven项目如图:

MyEclipse10搭建MavenSpringMVC注解JavaWeb项目

2、项目创建完毕后整体架构如图:

MyEclipse10搭建MavenSpringMVC注解JavaWeb项目

4、配置dispatcher-servlet.xml文件:<?xml version="1.0" encoding=&鳎溻趄酃quot;UTF-8"?><beans xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <context:annotation-config/> <context:component-scan base-package="com"> </context:component-scan> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" > <property name="messageConverters"> <ref bean="mappingJacksonHttpMessageConverter"/> </property> </bean> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- ViewResolver --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="requestContextAttribute" value="rc" /> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean></beans>

MyEclipse10搭建MavenSpringMVC注解JavaWeb项目

6、写一个程序跑一下项目结果如下,大功告成:

MyEclipse10搭建MavenSpringMVC注解JavaWeb项目
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢