1.在hot-deploy 下创建 hello1目录.加入ofbiz-component.xml文件.内容如下:
1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <ofbiz-component name="hello1"
4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5. xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/ofbiz-component.xsd">
6. <resource-loader name="main" type="component"/>
7. <webapp name="hello1"
8. title="My First OFBiz Application"
9. server="default-server"
10. location="webapp/hello1"
11. mount-point="/hello1"
12. app-bar-display="false"/>
13. </ofbiz-component>
2.在hello1下创建webapp目录.
3.webapp目录下创建hello1目录.
4.webapp/hello1下创建WEB-INF目录(此目录为java web工程必须的).
5.webapp/hello1下创建main.ftl文件.内容如下:
[code]<html>
<head>
<title>Hello World</title>
</head>
<body>
<h1>HELLO</h1>
<p>Hello world!</p>
</body>
</html>[/code]
6.webapp/hello1/WEB-INF下创建web.xml文件.
[code]<?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 1</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>hello1</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>
[/code]
7.webapp/hello1/WEB-INF下创建controller.xml文件.
[code]<?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>
[/code]
8.运行startofbiz.bat 启动服务.
9.打开IE,访问http://localhost:8080/hello1/control/main.即可访问到hello页面.
10.打开IE,访问http://localhost:8080/hello1/提示找不到页面.
在hello1\webapp\hello1加入index.jsp,做默认转向.
内容:[code]<%response.sendRedirect("control/main");%>[/code]
再次访问查看结果.