tomahawk在JSF部署

1 下载Myfaces、Tomahawk的jar包

首先需要的Myfaces的两个jar包

myfaces-api-1.X.X.jar

myfaces-impl-1.X.X.jar

要想使用Tomahawk还必须导入

tomahawk-1.1.X.jar

这三个jar可以到Myfaces的官方网站下载

http://myfaces.apache.org/download.html

导入这三个包之后,只要在web.xml进行简单的配置就可以了

2 web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<context-param>
		<param-name>javax.faces.CONFIG_FILES</param-name>
		<param-value>/WEB-INF/faces-config.xml</param-value>
	</context-param>
	
 <context-param>  
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>  
     <param-value>.xhtml</param-value>  
   </context-param>  
	<context-param>
		<param-name>org.richfaces.SKIN</param-name>
		<param-value>blueSky</param-value>
	</context-param>

	<filter>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<filter-class>
			org.apache.myfaces.webapp.filter.ExtensionsFilter
		</filter-class>
		<init-param>
			<param-name>uploadMaxFileSize</param-name>
			<param-value>20m</param-value>
		</init-param>
	</filter>

	<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->
	<filter-mapping>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>

	<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->
	<filter-mapping>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>
			org.apache.myfaces.webapp.StartupServletContextListener
		</listener-class>
	</listener>
	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.faces</url-pattern>
	</servlet-mapping>
	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	<login-config>
		<auth-method>BASIC</auth-method>
	</login-config>
</web-app>
 

上面代码中

<filter>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<filter-class>
			org.apache.myfaces.webapp.filter.ExtensionsFilter
		</filter-class>
		<init-param>
			<param-name>uploadMaxFileSize</param-name>
			<param-value>20m</param-value>
		</init-param>
	</filter>

	<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->
	<filter-mapping>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>

	<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->
	<filter-mapping>
		<filter-name>MyFacesExtensionsFilter</filter-name>
		<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
	</filter-mapping>
 

是为了使用Tomahawk做的配置,如果不适用Tomahawk,可以去掉这部分,部署完之后,可以使用Myfaces的Tomahawk拓展功能了,例如现在炒得很热的tree2组件,可以尝试一下。

你可能感兴趣的:(xml,Web,servlet,Richfaces,JSF)