接着就是写资源文件了。
在com.game.resources包中添加ApplicationResourcesProducts.properties文件。如果你的eclipse中有Properties Editor这个插件,就可以用Properties Editor打开资源文件进行编写,省去了用命令行转换格式的麻烦。配置内容如下:

- errors.required={0}不能为空.
- errors.minlength={0}不能小于 {1} 个字符.
- errors.maxlength={0}不能大于 {1} 个字符.
- errors.invalid={0}输入格式不对.
- errors.byte={0}必须为字节.
- errors.short={0}必须为短整型.
- errors.integer={0}必须为整型.
- errors.long={0}必须为长整型.
- errors.float={0}必须为浮点型.
- errors.double={0}必须为双精度型.
- errors.date={0}不是一个正确的日期或格式不对.
- errors.range={0} is not in the range {1} through {2}.
- errors.creditcard={0} is not a valid credit card number.
- errors.email={0}不是一个有效的email地址.
- errors.gameNameCn=游戏中文名称
- errors.gameNameEn=游戏英文名称
- errors.gameCapacity=碟数
- errors.gamePrice=价格
需要注意的是

接下来就是写页面文件了。在products文件夹中添加如下页面。
index.jsp页面代码:
- <%@ page contentType="text/html;charset=GBK" language="java" %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
- <title>游戏软件管理系统title>
- head>
- <body>
- <a href="/game/getProducts.do?method=doGetProducts&&flag=1">进入游戏软件管理单元a>
- body>
- html>
products.jsp页面代码:
- <%@page pageEncoding="GBK" contentType="text/html; charset=GBK" import="com.game.commons.Pager;"%>
- <%@ taglib uri="struts-html" prefix="html" %>
- <%@ taglib uri="struts-logic" prefix="logic" %>
- <%@ taglib uri="struts-bean" prefix="bean" %>
- <%
- String flag=(String)request.getAttribute("flag");
- String totalRows=(String)request.getAttribute("totalRows");
- String fieldname="";
- String value="";
- if(flag.equals("2")){
- fieldname=(String)request.getAttribute("fieldname");
- value=(String)request.getAttribute("value");
- }
- %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
- <title>title>
- <script language = "JavaScript">
- function btnQuery() {
- if(myfm.value.value=="")
- {
- alert("请输入查询关键字!");
- }else{
- window.location.href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname="+myfm.fieldname.value+"&&value="+myfm.value.value;
- }
- }
- script>
- head>
- <body>
- <form name="myfm" method="post">
- <table border="1">
- <tr>
- <td>
- <a href="/game/getProducts.do?method=doGetProducts&&flag=1">察看所有记录a>
- td>
- <td>
- <a href="/game/addProductPage.do?method=doAddProductPage&&flag=&&fieldname=&&value=">添加a>
- td>
- <td>
- <select name="fieldname" >
- <option value="gameNameCn">中文名称option>
- <option value="gameNameEn">英文名称option>
- <option value="gameCapacity">碟数option>
- <option value="gameVersion">版本option>
- <option value="gameMedia">介质option>
- <option value="gameCopyright">版权option>
- select>
- <input value="" name="value" />
- <a href="#" onclick="btnQuery()">查询a>
- td>
- tr>
- table>
- <br>
- <br>
- <table border="1">
- <tr>
- <td>游戏中文名称td>
- <td>游戏英文名称td>
- <td>软件版本td>
- <td>软件介质td>
- <td>碟数td>
- <td>版权td>
- <td>价格(元)td>
- <td>攻略td>
- tr>
- <logic:iterate id="pd" name="productsList">
- <tr>
- <td><a href="/game/getProduct.do?method=doGetProduct&&flag=<%=flag%>&&gameId=<bean:write name="pd" property="gameId"/>&&flag=&&fieldname=&&value="><bean:write name="pd" property="gameNameCn"/>a>td>
- <td><bean:write name="pd" property="gameNameEn"/>td>
- <td>
- <logic:equal name="pd" property="gameVersion" value="1">
- 中文版
- logic:equal>
- <logic:equal name="pd" property="gameVersion" value="2">
- 英文版
- logic:equal>
- td>
- <td>
- <logic:equal name="pd" property="gameMedia" value="1">
- CD
- logic:equal>
- <logic:equal name="pd" property="gameMedia" value="2">
- DVD5
- logic:equal>
- <logic:equal name="pd" property="gameMedia" value="3">
- DVD9
- logic:equal>
- td>
- <td><bean:write name="pd" property="gameCapacity"/>td>
- <td>
- <logic:equal name="pd" property="gameCopyright" value="1">
- 正版
- logic:equal>
- <logic:equal name="pd" property="gameCopyright" value="2">
- 翻版
- logic:equal>
- td>
- <td><bean:write name="pd" property="gamePrice"/>td>
- <td><bean:write name="pd" property="gameContent"/>td>
- tr>
- logic:iterate>
- <tr>
- <%if(flag.equals("1")){%>
- <td colspan="8" align="right" class="head">
- 共有<%=totalRows%>条记录
- 第<bean:write name="PAGER" property="currentPage"/>页
- 共<bean:write name="PAGER" property="totalPages"/>页
- <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=first" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">首页html:link>
- <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=previous" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">上一页html:link>
- <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=next" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">下一页html:link>
- <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=last" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">尾页html:link>
- td>
- <%}else if(flag.equals("2")){%>
- <% Pager pager=(Pager)request.getAttribute("PAGER");%>
- <td colspan="8" align="right" class="head">
- 共有<%=totalRows%>条记录
- 第<bean:write name="PAGER" property="currentPage"/>页
- 共<bean:write name="PAGER" property="totalPages"/>页
- <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=&&value=&&pagerMethod=first&¤tPage=" >首页a>
- <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=&&value=&&pagerMethod=previous&¤tPage=" >上一页a>
- <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=&&value=&&pagerMethod=next&¤tPage=" >下一页a>
- <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=&&value=&&pagerMethod=last&¤tPage=" >尾页a>
- td>
- <%}%>
- tr>
- table>
- form>
- body>
- html>