ICEfaces 和 Google Translate -5 步骤 3. 创建 web.xml 和 faces-config.xml
 
- UID
- 1066743
|
ICEfaces 和 Google Translate -5 步骤 3. 创建 web.xml 和 faces-config.xml
步骤 3. 创建 web.xml 和 faces-config.xml 文件web.xml 文件为构成 Web 应用程序的 Web 组件提供了配置和部署信息。这些信息必须位于 Web 应用程序目录层次结构的 WEB-INF 目录中。
显示了 web.xml 文件。
faces-config.xml 文件是 JavaServer Faces 配置文件。该文件列出了 bean 资源和导航规则。清单 5 显示了 faces-config.xml 文件的代码。
清单 5. faces-config.xml 文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<managed-bean>
<managed-bean-name>translate</managed-bean-name>
<managed-bean-class>
com.ibm.translate.GoogleTranslate
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
|
结束语本教程简述了如何使用 Google 的 Translate API 来构建简单翻译组件。将代码汇编到项目中之后,您应该能够像任何 Web 应用程序一样执行和部署它。在此基础上,您可以轻松地翻译粘贴的文本,或者为 Web 应用程序中的信息提供即时翻译。请继续探索无限可能。如有任何疑问或建议,请随时联系我们。
|
|
|
|
|
|