在MyEclipse中搭建Spring MVC开发环境
http://www.flypeng.com win10系统 发布时间:2015-04-01 14:26 来源:未知 浏览:加载中

环境版本 
IDE:MyEclipse 8.5 
Spring:spring 3.2.8 
JDK:1.6

1.打开MyEclipse-->File-->New-->Web Project,在打开的对话框里面输入project Name为SpringMvc,点击Finish。如下图所示:

image

2.在新建项目上右键选择,properties-->Java Build Path-->Libraries-->Add External JARs,引入spring-framework-3.2.8.RELEASE-dist目录下几个必需的jar包.

image

3.文件结构

image

4.web.

<??><web-app version="2.5" ="http://java.sun.com/    ="http://www.w3.org/2001/    xsi:schemaLocation="http://java.sun.com/>    <servlet>       <servlet-name>springmvc</servlet-name>       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>    </servlet>       <servlet-mapping>       <servlet-name>springmvc</servlet-name>       <!-- 监听所有请求 -->       <url-pattern>/</url-pattern>    </servlet-mapping></web-app>

5.springmvc-servlet.

<??><beans ="http://www.springframework.org/schema/beans"    ="http://www.w3.org/2001/    ="http://www.springframework.org/schema/context"    ="http://www.springframework.org/schema/mvc"    xsi:schemaLocation="       http://www.springframework.org/schema/mvc       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd       http://www.springframework.org/schema/beans       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd       http://www.springframework.org/schema/context       http://www.springframework.org/schema/context/spring-context-3.0.xsd">    <!-- 扫描所有的 controller -->    <context:component-scan base-package="com.springmvc.controllers" />    <!-- 启动注解驱动 SpringMVC 功能 -->    <mvc:annotation-driven />    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">       <property name="prefix" value="/views/" />       <property name="suffix" value=".jsp" />    </bean></beans>

6.在WebRoot目录下,新建views文件夹,添加index.jsp.

image

7.在com.springmvc.controllers包下,新建HomeController类文件,

image

8.部署项目运行,访问http://localhost:8080/SpringMvc/home,如下图示:

image

 
如果你有好的win10资讯或者win10教程,以及win10相关的问题想要获得win10系统下载的关注与报道。
欢迎加入发送邮件到657025171#qq.com(#替换为@)。期待你的好消息!