5. Web.xml内容
- <!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
- <web-app>
- <display-name>Archetype Created Web Application</display-name>
- <context-param>
- <param-name>contextClass</param-name>
- <param-value>
- org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext
- </param-value>
- </context-param>
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <servlet>
- <servlet-name>gloomyfish</servlet-name>
- <servlet-class>
- org.springframework.web.servlet.DispatcherServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>gloomyfish</servlet-name>
- <url-pattern>/app/*</url-pattern>
- </servlet-mapping>
- <welcome-file-list>
- <welcome-file>Hello.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
- <?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:context="http://www.springframework.org/schema/context"
- xmlns:mvc="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.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
- <context:component-scan base-package="com.gloomyfish.web" />
- <!-- enable anntotation-driven controllers -->
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
- <!-- configure FreeMarker support -->
- <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
- <property name="templateLoaderPath" value="/WEB-INF/ftl/" />
- </bean>
- <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
- <property name="cache" value="true" />
- <property name="suffix" value=".ftl" />
- </bean>
- </beans>
打包部署项目,使用Maven编译打包以后,选择配置好的Virgo Server图标,右键[Add and Remove]
在弹出的对话框中选则项目,点击add增加到Virgo Server点击finish

启动运行,选择绿色运行图标,启动Virgo Sever访问如下URL:
http://localhost:8080/gloomyfish, 看到效果是一个基于HTML5的太极图案,要求在支持HTML5的
浏览器上才可以看到效果如下:

项目打包源代码下载地址为:
免费下载地址在 http://linux.linuxidc.com/
用户名与密码都是www.linuxidc.com
具体下载目录在 /2012年资料/6月/17日/基于OSGi的Virgo Server最简单Spring web实例/
