注:转自它处
1.下载 ofbiz 9.04
2.将下载的文件解压在 E:盘下,改名:E:\ofbiz9
3.E:\ofbiz9\hot-deploy 下新建hello文件夹
4.E:\ofbiz9\hot-deploy\hello 下新建 webapp 文件夹和 ofbiz-component.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-component name="hello"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/ofbiz-component.xsd">
<resource-loader name="main" type="component"/>
<webapp name="hello"
title="My First OFBiz Application"
server="default-server"
location="webapp/hello"
mount-point="/hello"
app-bar-display="false"/>
</ofbiz-component>
5.E:\ofbiz9\hot-deploy\hello\webapp下新建 hello 文件夹
6.E:\ofbiz9\hot-deploy\hello\webapp\hello下分别新建 WEB-INF文件夹和 main.ftl文件
<h1>Hello OFbiz</h1>
<p>我的第一个测试页面正在运行...</p>
7.E:\ofbiz9\hot-deploy\hello\webapp\hello\WEB-INF下新建web.xml文件和controller.xml文件
web.xml:
<?xml version="1.0"?>
<!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>Hello</display-name>
<description>The First Hello World Application</description>
<context-param>
<param-name>entityDelegatorName</param-name>
<param-value>default</param-value>
<description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
</context-param>
<context-param>
<param-name>localDispatcherName</param-name>
<param-value>hello</param-value>
<description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
</context-param>
<context-param>
<param-name>serviceReaderUrls</param-name>
<param-value>/WEB-INF/services.xml</param-value>
<description>Configuration File(s) For The Service Dispatcher</description>
</context-param>
<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/main</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>
<!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface -->
<!-- <listener><listener-class>
org.ofbiz.webapp.control.ControlActivationEventListener</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> <!-- in minutes -->
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
</web-app>
controller.xml
<?xml version="1.0" encoding="UTF-8" ?>
<site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/site-conf.xsd">
<description>First Hello World Site Configuration File</description>
<owner>Open For Business Project (c) 2005 </owner>
<errorpage>/error/error.jsp</errorpage>
<handler name="java" type="request" class="org.ofbiz.webapp.event.JavaEventHandler"/>
<handler name="soap" type="request" class="org.ofbiz.webapp.event.SOAPEventHandler"/>
<handler name="service" type="request" class="org.ofbiz.webapp.event.ServiceEventHandler"/>
<handler name="service-multi" type="request" class="org.ofbiz.webapp.event.ServiceMultiEventHandler"/>
<handler name="simple" type="request" class="org.ofbiz.webapp.event.SimpleEventHandler"/>
<handler name="ftl" type="view" class="org.ofbiz.webapp.ftl.FreeMarkerViewHandler"/>
<handler name="jsp" type="view" class="org.ofbiz.webapp.view.JspViewHandler"/>
<handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
<handler name="http" type="view" class="org.ofbiz.webapp.view.HttpViewHandler"/>
<preprocessor>
<!-- Events to run on every request before security (chains exempt) -->
<!-- <event type="java" path="org.ofbiz.webapp.event.TestEvent" invoke="test"/> -->
<event type="java" path="org.ofbiz.securityext.login.LoginEvents" invoke="checkExternalLoginKey"/>
</preprocessor>
<postprocessor>
<!-- Events to run on every request after all other processing (chains exempt) -->
<!-- <event type="java" path="org.ofbiz.webapp.event.TestEvent" invoke="test"/> -->
</postprocessor>
<!-- Request Mappings -->
<request-map uri="main">
<response name="success" type="view" value="main"/>
</request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
<view-map name="error" page="/error/error.jsp"/>
<view-map name="main" type="ftl" page="main.ftl"/>
<!-- end of view mappings -->
</site-conf>
8.运行 E:\ofbiz9 下startofbiz.bat
9.稍等几秒 输入http://localhost:8080/hello/,页面显示如下:
Hello OFbiz
我的第一个测试页面正在运行...