1.web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!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 id="WebApp_ID">
<context-param>
<!-- Faces Context Configuration -->
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/config/faces-config.xml</param-value>
</context-param><!-- Tomahawk TLD文件配置-->
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/tld/tomahawk.taglib.xml</param-value>
</context-param><!-- 视图文件的后缀解析配置 -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.html</param-value>
</context-param>
<!-- Tomanawk ExtensionsFilter的配置 -->
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>
org.apache.myfaces.webapp.filter.ExtensionsFilter
</filter-class>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>10m</param-value>
</init-param>
</filter><!-- ExtensionsFilter的配置
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>如果不使用Facelets,需要配置此项-->
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.page</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<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>*.page</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>这是最简要的配置。
2。faces-config.xml配置
<application><!--增加Facelet视图处理器 -->

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<message-bundle>resources.application</message-bundle>
<locale-config>
<default-locale>zh_CN</default-locale>
</locale-config>
</application>
3.tomahawk.taglib.xml文件
在WEB-INF/tld目录下增加tomahawk.taglib.xml文件
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://myfaces.apache.org/tomahawk</namespace>
<tag>
<tag-name>aliasBean</tag-name>
<component>
<component-type>
org.apache.myfaces.AliasBean
</component-type>
<renderer-type>org.apache.myfaces.AliasBean</renderer-type>
</component>
</tag>
<tag>
<tag-name>buffer</tag-name>
<component>
<component-type>org.apache.myfaces.Buffer</component-type>
<renderer-type>org.apache.myfaces.Buffer</renderer-type>
</component>
</tag>
<tag>
<tag-name>columns</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlColumns
</component-type>
</component>
</tag>
<tag>
<tag-name>column</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlColumn
</component-type>
</component>
</tag>
<tag>
<tag-name>commandButton</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlCommandButton
</component-type>
</component>
</tag>
<tag>
<tag-name>commandLink</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlCommandLink
</component-type>
</component>
</tag>
<tag>
<tag-name>commandNavigation</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlCommandNavigation
</component-type>
<renderer-type>javax.faces.Link</renderer-type>
</component>
</tag>
<tag>
<tag-name>commandSortHeader</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlCommandSortHeader
</component-type>
<renderer-type>org.apache.myfaces.SortHeader</renderer-type>
</component>
</tag>
<tag>
<tag-name>dataList</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlDataList
</component-type>
<renderer-type>org.apache.myfaces.List</renderer-type>
</component>
</tag>
<tag>
<tag-name>dataScroller</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlDataScroller
</component-type>
<renderer-type>
org.apache.myfaces.DataScroller
</renderer-type>
</component>
</tag>
<tag>
<tag-name>dataTable</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlDataTable
</component-type>
<renderer-type>org.apache.myfaces.Table</renderer-type>
</component>
</tag>
<tag>
<tag-name>div</tag-name>
<component>
<component-type>org.apache.myfaces.Div</component-type>
</component>
</tag>
<tag>
<tag-name>graphicImage</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlGraphicImage
</component-type>
<renderer-type>javax.faces.Image</renderer-type>
</component>
</tag>
<tag>
<tag-name>htmlTag</tag-name>
<component>
<component-type>org.apache.myfaces.HtmlTag</component-type>
<renderer-type>
org.apache.myfaces.HtmlTagRenderer
</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputFileUpload</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputFileUpload
</component-type>
<renderer-type>org.apache.myfaces.FileUpload</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputCalendar</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputCalendar
</component-type>
<renderer-type>org.apache.myfaces.Calendar</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputDate</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputDate
</component-type>
<renderer-type>org.apache.myfaces.Date</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputHidden</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputHidden
</component-type>
</component>
</tag>
<tag>
<tag-name>inputHtml</tag-name>
<component>
<component-type>
org.apache.myfaces.InputHtml
</component-type>
<renderer-type>org.apache.myfaces.InputHtml</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputSecret</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputSecret
</component-type>
<renderer-type>org.apache.myfaces.Secret</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputText</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputText
</component-type>
<renderer-type>org.apache.myfaces.Text</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputTextarea</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputTextarea
</component-type>
<renderer-type>org.apache.myfaces.Textarea</renderer-type>
</component>
</tag>
<tag>
<tag-name>inputTextHelp</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlInputTextHelp
</component-type>
<renderer-type>org.apache.myfaces.TextHelp</renderer-type>
</component>
</tag>
<tag>
<tag-name>message</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlMessage
</component-type>
<renderer-type>org.apache.myfaces.Message</renderer-type>
</component>
</tag>
<tag>
<tag-name>messages</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlMessages
</component-type>
<renderer-type>org.apache.myfaces.Messages</renderer-type>
</component>
</tag>
<tag>
<tag-name>jscookMenu</tag-name>
<component>
<component-type>
org.apache.myfaces.JSCookMenu
</component-type>
<renderer-type>org.apache.myfaces.JSCookMenu</renderer-type>
</component>
</tag>
<tag>
<tag-name>navigationMenuItem</tag-name>
<component>
<component-type>
org.apache.myfaces.NavigationMenuItem
</component-type>
</component>
</tag>
<tag>
<tag-name>navigationMenuItems</tag-name>
<component>
<component-type>javax.faces.SelectItems</component-type>
</component>
</tag>
<tag>
<tag-name>newspaperTable</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlNewspaperTable
</component-type>
<renderer-type>
org.apache.myfaces.HtmlNewspaperTable
</renderer-type>
</component>
</tag>
<tag>
<tag-name>outputText</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlOutputText
</component-type>
<renderer-type>org.apache.myfaces.Text</renderer-type>
</component>
</tag>
<tag>
<tag-name>panelNavigation</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlPanelNavigation
</component-type>
<renderer-type>org.apache.myfaces.Navigation</renderer-type>
</component>
</tag>
<tag>
<tag-name>panelNavigation2</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlPanelNavigationMenu
</component-type>
<renderer-type>
org.apache.myfaces.NavigationMenu
</renderer-type>
</component>
</tag>
<tag>
<tag-name>panelTab</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlPanelTab
</component-type>
<renderer-type>javax.faces.Group</renderer-type>
</component>
</tag>
<tag>
<tag-name>panelTabbedPane</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlPanelTabbedPane
</component-type>
<renderer-type>org.apache.myfaces.TabbedPane</renderer-type>
</component>
</tag>
<tag>
<tag-name>popup</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlPopup
</component-type>
<renderer-type>org.apache.myfaces.Popup</renderer-type>
</component>
</tag>
<tag>
<tag-name>radio</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlRadio
</component-type>
<renderer-type>org.apache.myfaces.Radio</renderer-type>
</component>
</tag>
<tag>
<tag-name>saveState</tag-name>
<component>
<component-type>
org.apache.myfaces.SaveState
</component-type>
</component>
</tag>
<tag>
<tag-name>selectBooleanCheckbox</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectBooleanCheckbox
</component-type>
<renderer-type>org.apache.myfaces.Checkbox</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectManyCheckbox</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectManyCheckbox
</component-type>
<renderer-type>org.apache.myfaces.Checkbox</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectManyListbox</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectManyListbox
</component-type>
<renderer-type>org.apache.myfaces.Listbox</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectManyMenu</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectManyMenu
</component-type>
<renderer-type>org.apache.myfaces.Menu</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectOneCountry</tag-name>
<component>
<component-type>
org.apache.myfaces.SelectOneCountry
</component-type>
<renderer-type>
org.apache.myfaces.SelectOneCountryRenderer
</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectOneLanguage</tag-name>
<component>
<component-type>
org.apache.myfaces.SelectOneLanguage
</component-type>
<renderer-type>
org.apache.myfaces.SelectOneLanguageRenderer
</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectOneListbox</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectOneListbox
</component-type>
<renderer-type>org.apache.myfaces.Listbox</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectOneMenu</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectOneMenu
</component-type>
<renderer-type>org.apache.myfaces.Menu</renderer-type>
</component>
</tag>
<tag>
<tag-name>selectOneRadio</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlSelectOneRadio
</component-type>
<renderer-type>org.apache.myfaces.Radio</renderer-type>
</component>
</tag>
<tag>
<tag-name>stylesheet</tag-name>
<component>
<component-type>
org.apache.myfaces.Stylesheet
</component-type>
</component>
</tag>
<!-- Note that "tree" will not work as-is. Tree either needs a facelets
TagHandler, or a refactoring of
org.apache.myfaces.custom.tree.taglib.TreeTag
and org.apache.myfaces.custom.tree.HtmlTree
to remove non-standard internal "model" attribute usage. -->
<tag>
<tag-name>tree</tag-name>
<component>
<component-type>org.apache.myfaces.HtmlTree</component-type>
<renderer-type>org.apache.myfaces.HtmlTree</renderer-type>
</component>
</tag>
<tag>
<tag-name>tree2</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlTree2
</component-type>
<renderer-type>org.apache.myfaces.HtmlTree2</renderer-type>
</component>
</tag>
<tag>
<tag-name>treeColumn</tag-name>
<component>
<component-type>
org.apache.myfaces.HtmlTreeColumn
</component-type>
</component>
</tag>
<tag>
<tag-name>document</tag-name>
<component>
<component-type>org.apache.myfaces.Document</component-type>
</component>
</tag>
<tag>
<tag-name>documentHead</tag-name>
<component>
<component-type>
org.apache.myfaces.DocumentHead
</component-type>
</component>
</tag>
<tag>
<tag-name>documentBody</tag-name>
<component>
<component-type>
org.apache.myfaces.DocumentBody
</component-type>
</component>
</tag>
<tag>
<tag-name>validateEmail</tag-name>
<validator>
<validator-id>
org.apache.myfaces.validator.Email
</validator-id>
</validator>
</tag>
<tag>
<tag-name>validateEqual</tag-name>
<validator>
<validator-id>
org.apache.myfaces.validator.Equal
</validator-id>
</validator>
</tag>
<tag>
<tag-name>validateRegExpr</tag-name>
<validator>
<validator-id>
org.apache.myfaces.validator.RegExpr
</validator-id>
</validator>
</tag>
</facelet-taglib>
FAQ:
1。以JSP作为视图,使用Tomahawk标签的必须在web.xml中添加配置
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
2。使用Facelets的Template模板文件,包含的所有页面不能包含<head></head>标签,建议只保留<body/>体内的内容。
3。css的引用必须在Template模板文件中指定,另外必须添加应用的根:
<link href="/um/css/basic.css" rel="stylesheet" type="text/css" />
浙公网安备 33010602011771号