Spring MVC快速教程:安装 Spring MVC Fast Tutorial: Setup

Spring MVC Fast Tutorial: Setup

:!: This tutorial is out of date. See the new version for Spring 4.

You'll need java 1.5, ant and tomcat. We're going to:

  1. create a web app skeleton
  2. add build files
  3. add required JARs

Web App Skeleton

Create a new folder 'springmvc'.

Inside, create these folders: 'classes', 'jsp', 'WEB-INF'.

In 'jsp', add 'index.jsp':

<html>
  <body>
    <p>Hi</p>
  </body>
</html>

In 'WEB-INF', add 'web.xml' and create the folder 'src':

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
  <welcome-file-list>
    <welcome-file>
      jsp/index.jsp
    </welcome-file>
  </welcome-file-list>
 
</web-app>

Add 'springmvc' folder to Tomcat webapps's folder, launch Tomcat and test (your Tomcat port may differ): http://localhost:8180/springmvc/

Build files

In 'WEB-INF', add 'build.properties': (update Tomcat path)

appserver.home=/usr/share/tomcat5.5
appserver.lib=${appserver.home}/common/lib

In 'WEB-INF', add 'build.xml':

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build">
 
  <property file="build.properties"/>
  <property name="src.dir" value="src"/>
  <property name="build.dir" value="classes"/>
 
  <path id="build.classpath">
      <fileset dir="lib">
          <include name="*.jar"/>
      </fileset>
      <fileset dir="${appserver.lib}"> <!-- servlet API classes: -->
          <include name="servlet*.jar"/>
      </fileset>
      <pathelement path="${build.dir}"/>
  </path>		
 
  <target name="build">
      <mkdir dir="${build.dir}"/>
      <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
          <src path="${src.dir}"/>
          <classpath refid="build.classpath"/>
      </javac>
  </target>
 
  <target name="clean" description="Clean output directories">
      <delete>
          <fileset dir="${build.dir}">
              <include name="**/*.class"/>
          </fileset>
      </delete>
  </target>
 
</project>

JARs

In 'WEB-INF', create the folder 'lib'.

Add into it these JARs from Spring distribution (with dependencies):

  • spring-framework/dist/spring.jar
  • spring-framework/dist/modules/spring-webmvc.jar
  • spring-framework/lib/jakarta-taglibs/standard.jar
  • spring-framework/lib/jakarta-commons/commons-logging.jar
  • spring-framework/lib/j2ee/servlet-api.jar
  • spring-framework/lib/j2ee/jstl.jar

Summary

You can download it here.


from: http://jeromejaglale.com/doc/java/spring/setup

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值