手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

基于OSGi的Virgo Server最简单Spring web实例

[日期:2012-06-17] 来源:Linux社区  作者:jia20003 [字体:大 中 小]

5.  Web.xml内容

  1. <!DOCTYPE web-app PUBLIC  
  2.  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  3.  "http://java.sun.com/dtd/web-app_2_3.dtd" >  
  4.   
  5. <web-app>  
  6.     <display-name>Archetype Created Web Application</display-name>  
  7.     <context-param>  
  8.         <param-name>contextClass</param-name>  
  9.         <param-value>  
  10.             org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext  
  11.         </param-value>  
  12.     </context-param>  
  13.     <listener>  
  14.         <listener-class>  
  15.             org.springframework.web.context.ContextLoaderListener  
  16.         </listener-class>  
  17.     </listener>  
  18.     <servlet>  
  19.         <servlet-name>gloomyfish</servlet-name>  
  20.         <servlet-class>  
  21.             org.springframework.web.servlet.DispatcherServlet  
  22.         </servlet-class>  
  23.         <load-on-startup>1</load-on-startup>  
  24.     </servlet>  
  25.     <servlet-mapping>  
  26.         <servlet-name>gloomyfish</servlet-name>  
  27.         <url-pattern>/app/*</url-pattern>  
  28.     </servlet-mapping>  
  29.     <welcome-file-list>  
  30.         <welcome-file>Hello.jsp</welcome-file>  
  31.     </welcome-file-list>  
  32. </web-app>  
6. gloomyfish-servlet.xml内容
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4. xmlns:context="http://www.springframework.org/schema/context"  
  5. xmlns:mvc="http://www.springframework.org/schema/mvc"  
  6. xsi:schemaLocation="http://www.springframework.org/schema/mvc  
  7. http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
  8. http://www.springframework.org/schema/beans  
  9. http://www.springframework.org/schema/beans/spring-beans.xsd  
  10. http://www.springframework.org/schema/context  
  11. http://www.springframework.org/schema/context/spring-context.xsd">  
  12.   
  13. <context:component-scan base-package="com.gloomyfish.web" />  
  14. <!-- enable anntotation-driven controllers -->  
  15. <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />  
  16.   
  17. <!-- configure FreeMarker support -->  
  18. <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">  
  19.     <property name="templateLoaderPath" value="/WEB-INF/ftl/" />  
  20. </bean>  
  21.   
  22. <bean id="viewResolver"  class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">  
  23.     <property name="cache" value="true" />  
  24.     <property name="suffix" value=".ftl" />  
  25. </bean>  
  26. </beans>  

打包部署项目,使用Maven编译打包以后,选择配置好的Virgo Server图标,右键[Add and Remove]

在弹出的对话框中选则项目,点击add增加到Virgo Server点击finish

基于OSGi的Virgo Server最简单Spring web实例

启动运行,选择绿色运行图标,启动Virgo Sever访问如下URL:

http://localhost:8080/gloomyfish, 看到效果是一个基于HTML5的太极图案,要求在支持HTML5的

浏览器上才可以看到效果如下:

基于OSGi的Virgo Server最简单Spring web实例

项目打包源代码下载地址为:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/6月/17日/基于OSGi的Virgo Server最简单Spring web实例/

linux
相关资讯       OSGi  Spring教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款