设为首页 收藏本站
查看: 1073|回复: 0

[经验分享] Apache OFBIZ快速上手(一)--简单例子

[复制链接]

尚未签到

发表于 2015-11-14 08:30:38 | 显示全部楼层 |阅读模式
           本篇文章主要介绍简单例子,OFBIZ的其他介绍就先不说了,放在后面的博文中。

1、目录结构

                   DSC0000.jpg



   说明:在hot-deploy目录下建立文件夹learning,为例。注意先把文件扔到hot-deploy目录下再启动服务器。
  



2、创建ofbiz-component.xml文件


            a.作用:创建此文件,负责让OFBIZ知道learning组件的信息,可以参考applications/accounting/ofbiz-component.xml。
            b.内容如下:

<span style=&quot;font-size:18px;&quot;><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<ofbiz-component name=&quot;learning&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:noNamespaceSchemaLocation=&quot;http://ofbiz.apache.org/dtds/ofbiz-component.xsd&quot;>
<resource-loader name=&quot;main&quot; type=&quot;component&quot;/>
<webapp name=&quot;learning&quot;
title=&quot;Learning&quot;
server=&quot;default-server&quot;
base-permission=&quot;OFBTOOLS&quot;
location=&quot;webapp/learning&quot;
mount-point=&quot;/learning&quot;
app-bar-display=&quot;false&quot;/>
</ofbiz-component>
</span>
        说明:第一个节点中name=”learning”,指的是组件名,告诉OFBIZ加载我们自己定义的name组件,这个名字必须唯一,不能与OFBIZ其他组件名相同。


      Webapp节点:

                name: 定义web应用的名字

                  title: 这个是应用的标识,显示在应用工具条中的名字

              server: 让ofbiz知道是哪个server

             location:learning组件指向的webapp的路径,这里用的是相对路径

       mount-point:应用的访问路径

app-bar-display:应用的title是否要显示







3、创建web.xml
           a.路径:${learning/webapp/learning}/WEB-INF
           b.内容:(基本每个web.xml都是一样的,从applications里面拷贝一个过来即可)

<span style=&quot;font-size:18px;&quot;><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<!DOCTYPE web-app PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web  
Application 2.3//EN&quot; &quot;http://java.sun.com/dtd/web-app_2_3.dtd&quot;>
<web-app>
<display-name>learning</display-name>
<description>The First Hello World Application</description>
<context-param>
<param-name>entityDelegatorName</param-name>
<param-value>default</param-value>
</context-param>
<!-- 本地调用名 start 刘腾腾 -->
<context-param>
<param-name>localDispatcherName</param-name>
<param-value>learning</param-value>
</context-param>
<!-- 本地调用名 end 刘腾腾 -->
<!-- 主修饰器位置,值应该与ofbiz-component.xml里的mount-point相匹配    start 刘腾腾 -->
<context-param>
<param-name>mainDecoratorLocation</param-name>
<param-value>component://simple/widget/CommonScreen.xml</param-value>
<description>The location of the main-decorator screen to use for
this webapplreferred to as a context variable in screen
def XML files.</description>
</context-param>
<!-- 主修饰器位置,值应该与ofbiz-component.xml里的mount-point相匹配    end 刘腾腾 -->
<filter>
<filter-name>ContextFilter</filter-name>
<display-name>ContextFilter</display-name>
<filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
<init-param>
<param-name>disableContextSecurity</param-name>
<param-value>N</param-value>
</init-param>
<init-param>
<param-name>allowedPaths</param-name>
<param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css</param-value>
</init-param>
<init-param>
<param-name>errorCode</param-name>
<param-value>403</param-value>
</init-param>
<init-param>
<param-name>redirectPath</param-name>
<param-value>/control/learning</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.ofbiz.webapp.control.ControlEventListener</listener-class>
</listener>
<listener>
<listener-class>org.ofbiz.webapp.control.LoginEventListener</listener-class>
</listener>
<servlet>
<servlet-name>ControlServlet</servlet-name>
<display-name>ControlServlet</display-name>
<description>Main Control Servlet</description>
<servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ControlServlet</servlet-name>
<url-pattern>/control/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
</span>



4、创建controller.xml
  
   a.作用:让OFBIZ根据不同的请求去做相应的事。
            b.内容

<span style=&quot;font-size:18px;&quot;><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<site-conf xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;xsi:noNamespaceSchemaLocation=&quot;http://ofbiz.apache.org/dtds/site-conf.xsd&quot;>
<!-- 引入OFBIZ的公共控制配置 ltt -->
<include location=&quot;component://common/webcommon/WEB-INF/common-controller.xml&quot;/>
<description>Practice Component Site Configuration File</description>
<owner>Copyright 2001-2009 The Apache Software Foundation</owner>
<!-- OFBIZ调用该class处理screen中的xml -->
<handler name=&quot;screen&quot; type=&quot;view&quot; class=&quot;org.ofbiz.widget.screen.ScreenWidgetViewHandler&quot;/>
<!-- Request Mappings -->
<request-map uri=&quot;main&quot;>
<security https=&quot;false&quot; auth=&quot;false&quot;/>
<response name=&quot;success&quot; type=&quot;view&quot; value=&quot;main&quot;/>
</request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
<view-map name=&quot;main&quot; type=&quot;screen&quot; page=&quot;component://simple/widget/SimpleScreens.xml#main&quot;/>
<!-- change the path to the following if the above doesn't work for you -->
<!-- end of view mappings -->
</site-conf>
</span>



5、简单页面
  
       a. 路径:${learning/widget}
             b. 建LearningScreen.xml

<span style=&quot;font-size:18px;&quot;><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<Screens xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;http://www.ofbiz.org/dtds/widget-screen.xsd&quot;>
<screen name=&quot;main&quot;>
<section>
<widgets>
<label text=&quot;===========liutengteng=======is a good girl!========&quot;/>
</widgets>
</section>
</screen>
</Screens></span>




6、运行结果
  
            a.地址   http://localhost:8080/learning/control/main
            b. 效果
DSC0001.jpg
  



7、总结
          这是一个简单的OFBIZ的入门小例子,通过一些配置文件,就将我们的系统搭起来了,很快捷,项目的加载部署也很快,灵活配置。下面博文将持续介绍OFBIZ。
  



版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-138985-1-1.html 上篇帖子: centos Apache、php、mysql默认安装路径 下篇帖子: 解决Apache/PHP无法启动的问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表