网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容 知识问答

MyEclipse10搭建MavenSpringMVC注解JavaWeb项目

时间:2024-10-22 17:47:28

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项目
© 2025 智德知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com