2014-10-22springmvc开发基础框架的搭建

说明: 使用springmvc已经半年多了,说真的刚开始的时候我只是听说过,从来都没有用过,来了之后老大让直接上手我也只是模仿,其中原理一概不知。
现在我也是一知半解,不过自己从来没有搭建过环境,今天闲下来网上搜点资料自己着手搭建一个springmvc项目。
第一步: 引入springmvc开发所需要的jar包

第二步:搭建springmvc项目,设置配置文件

<span style="font-size:18px;"><span style="color:#ff0000;">     先配置web.xml</span>
          <servlet>
	     <servlet-name>springmvc</servlet-name>
	     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                      <init-param>
	   <param-name>contextConfigLocation</param-name>
	   <param-value>/WEB-INF/springmvc-servlet.xml</param-value>
	  </init-param>
	  <load-on-startup>2</load-on-startup>
          </servlet>
         <servlet-mapping>
		<servlet-name>springmvc</servlet-name>
		<url-pattern>*.do</url-pattern>
         </servlet-mapping></span>
<span style="font-size:18px;">   <span style="color:#ff0000;"> 其次配置springmvc-servlet.xml</span>
         <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
		http://www.springframework.org/schema/mvc 
		http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context-3.0.xsd 
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">				
		<!--基于注解的开发-->
		<mvc:annotation-driven/>
		<context:component-scan base-package="com.soufun.act"/>
		<!-- 前缀+ viewName +后缀 -->
		<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
			<!-- webroot到某一指定的文件夹的路径 -->
			<property name="prefix" value="/WEB-INF/jsp/"></property>
			<!-- 视图名称的后缀 -->
			<property name="suffix" value=".jsp"></property>
		</bean>
</beans></span>
第三步:写好前台和后台代码。


这些都简单,可以自己上网搜,主要是搭好环境。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值