接着就是寫資源文件了。
在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=價格
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>
<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=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= 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=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= 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=<%=fieldname%>&&value=<%= value%>&&pagerMethod=first&¤tPage=<%=pager.getCurrentPage()%>" >首頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=previous&¤tPage=<%=pager.getCurrentPage()%>" >上一頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=next&¤tPage=<%=pager.getCurrentPage()%>" >下一頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=last&¤tPage=<%=pager.getCurrentPage()%>" >尾頁</a>
</td>
<%}%>
</tr>
</table>
</form>
</body>
</html>
<%@ 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=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= 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=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= 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=<%=fieldname%>&&value=<%= value%>&&pagerMethod=first&¤tPage=<%=pager.getCurrentPage()%>" >首頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=previous&¤tPage=<%=pager.getCurrentPage()%>" >上一頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=next&¤tPage=<%=pager.getCurrentPage()%>" >下一頁</a>
<a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<%=fieldname%>&&value=<%= value%>&&pagerMethod=last&¤tPage=<%=pager.getCurrentPage()%>" >尾頁</a>
</td>
<%}%>
</tr>
</table>
</form>
</body>
</html>
addproduct.jsp頁面代碼:
<%@page pageEncoding="GBK" contentType="text/html; charset=GBK" %>
<%@ 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 fieldname="";
String value="";
if(flag.equals("2")){
fieldname=(String)request.getAttribute("fieldname");
value=(String)request.getAttribute("value");
}
String maxid=(String)request.getAttribute("maxid");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
<title></title>
<html:base/>
<html:javascript formName="productsForm" method="validate"/>
<script Language="JavaScript">
function btn_AddFolder() {
if(confirm("確定要保存嗎?")){
if(document.productsForm.onsubmit()){
document.forms[0].submit();
}
}
}
</script>
</head>
<body>
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<html:form action="/addProduct.do" onsubmit="return validate(this)">
<table border="1">
<tr>
<td>遊戲中文名稱</td>
<td>遊戲英文名稱</td>
<td>軟件版本</td>
<td>軟件介質</td>
<td>碟數</td>
<td>版權</td>
<td>價格(元)</td>
<td>攻略</td>
</tr>
<tr>
<td><html:text property="gameNameCn"/></td>
<td><html:text property="gameNameEn"/></td>
<td>
<html:select property="gameVersion" >
<html:option value= "2">英文版 </html:option>
<html:option value= "1">中文版</html:option>
</html:select>
</td>
<td>
<html:select property="gameMedia" >
<html:option value= "1">CD </html:option>
<html:option value= "2">DVD5</html:option>
<html:option value= "3">DVD9</html:option>
</html:select>
</td>
<td><html:text property="gameCapacity" size="5"/></td>
<td>
<html:select property="gameCopyright" >
<html:option value= "2">翻版 </html:option>
<html:option value= "1">正版</html:option>
</html:select>
</td>
<td><html:text property="gamePrice"/></td>
<td><html:text property="gameContent"/></td>
</tr>
</table>
<html:hidden property="gameId" value="<%= maxid%>"/>
<html:hidden property="method" value="doAddProduct"/>
<html:hidden property="flag" value="<%= flag%>"/>
<html:hidden property="fieldname" value="<%= fieldname%>"/>
<html:hidden property="value" value="<%=value%>"/>
<input type="button" value="保存" onclick="btn_AddFolder()"/>
</html:form>
</body>
</html>
<%@ 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 fieldname="";
String value="";
if(flag.equals("2")){
fieldname=(String)request.getAttribute("fieldname");
value=(String)request.getAttribute("value");
}
String maxid=(String)request.getAttribute("maxid");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
<title></title>
<html:base/>
<html:javascript formName="productsForm" method="validate"/>
<script Language="JavaScript">
function btn_AddFolder() {
if(confirm("確定要保存嗎?")){
if(document.productsForm.onsubmit()){
document.forms[0].submit();
}
}
}
</script>
</head>
<body>
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<html:form action="/addProduct.do" onsubmit="return validate(this)">
<table border="1">
<tr>
<td>遊戲中文名稱</td>
<td>遊戲英文名稱</td>
<td>軟件版本</td>
<td>軟件介質</td>
<td>碟數</td>
<td>版權</td>
<td>價格(元)</td>
<td>攻略</td>
</tr>
<tr>
<td><html:text property="gameNameCn"/></td>
<td><html:text property="gameNameEn"/></td>
<td>
<html:select property="gameVersion" >
<html:option value= "2">英文版 </html:option>
<html:option value= "1">中文版</html:option>
</html:select>
</td>
<td>
<html:select property="gameMedia" >
<html:option value= "1">CD </html:option>
<html:option value= "2">DVD5</html:option>
<html:option value= "3">DVD9</html:option>
</html:select>
</td>
<td><html:text property="gameCapacity" size="5"/></td>
<td>
<html:select property="gameCopyright" >
<html:option value= "2">翻版 </html:option>
<html:option value= "1">正版</html:option>
</html:select>
</td>
<td><html:text property="gamePrice"/></td>
<td><html:text property="gameContent"/></td>
</tr>
</table>
<html:hidden property="gameId" value="<%= maxid%>"/>
<html:hidden property="method" value="doAddProduct"/>
<html:hidden property="flag" value="<%= flag%>"/>
<html:hidden property="fieldname" value="<%= fieldname%>"/>
<html:hidden property="value" value="<%=value%>"/>
<input type="button" value="保存" onclick="btn_AddFolder()"/>
</html:form>
</body>
</html>
product.jsp頁面代碼:
<%@page pageEncoding="GBK" contentType="text/html; charset=GBK" %>
<%@ 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 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>
<html:javascript formName="productsForm" method="validate"/>
</head>
<body>
<a href="/game/addProductPage.do?method=doAddProductPage&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">添加</a>
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<a href="/game/deleteProduct.do?method=doDeleteProduct&&flag=<%= flag%>&&gameId=<bean:write name="pd" property="gameId"/>&&fieldname=<%=fieldname%>&&value=<%= value%>">刪除</a>
<br>
<br>
<html:form action="/updateProduct.do" onsubmit="return validate(this)">
<table border="1">
<tr>
<td>遊戲中文名稱</td>
<td>遊戲英文名稱</td>
<td>軟件版本</td>
<td>軟件介質</td>
<td>碟數</td>
<td>版權</td>
<td>價格(元)</td>
<td>攻略</td>
</tr>
<tr>
<td><html:text name="pd" property="gameNameCn"/></td>
<td><html:text name="pd" property="gameNameEn"/></td>
<td>
<html:select name="pd" property="gameVersion" >
<html:option value= "1">中文版 </html:option>
<html:option value= "2">英文版</html:option>
</html:select>
</td>
<td>
<html:select name="pd" property="gameMedia" >
<html:option value= "1">CD </html:option>
<html:option value= "2">DVD5</html:option>
<html:option value= "3">DVD9</html:option>
</html:select>
</td>
<td><html:text name="pd" property="gameCapacity" size="5"/></td>
<td>
<html:select name="pd" property="gameCopyright" >
<html:option value= "1">正版 </html:option>
<html:option value= "2">翻版</html:option>
</html:select>
</td>
<td><html:text name="pd" property="gamePrice" size="10"/></td>
<td><html:text name="pd" property="gameContent"/></td>
</tr>
</table>
<html:hidden property="method" value="doUpdateProduct"/>
<html:hidden name="pd" property="gameId" />
<html:hidden property="flag" value="<%= flag%>"/>
<html:hidden property="fieldname" value="<%= fieldname%>"/>
<html:hidden property="value" value="<%=value%>"/>
<html:submit property="submit" value="保存"></html:submit>
</html:form>
</body>
</html>
<%@ 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 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>
<html:javascript formName="productsForm" method="validate"/>
</head>
<body>
<a href="/game/addProductPage.do?method=doAddProductPage&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">添加</a>
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<a href="/game/deleteProduct.do?method=doDeleteProduct&&flag=<%= flag%>&&gameId=<bean:write name="pd" property="gameId"/>&&fieldname=<%=fieldname%>&&value=<%= value%>">刪除</a>
<br>
<br>
<html:form action="/updateProduct.do" onsubmit="return validate(this)">
<table border="1">
<tr>
<td>遊戲中文名稱</td>
<td>遊戲英文名稱</td>
<td>軟件版本</td>
<td>軟件介質</td>
<td>碟數</td>
<td>版權</td>
<td>價格(元)</td>
<td>攻略</td>
</tr>
<tr>
<td><html:text name="pd" property="gameNameCn"/></td>
<td><html:text name="pd" property="gameNameEn"/></td>
<td>
<html:select name="pd" property="gameVersion" >
<html:option value= "1">中文版 </html:option>
<html:option value= "2">英文版</html:option>
</html:select>
</td>
<td>
<html:select name="pd" property="gameMedia" >
<html:option value= "1">CD </html:option>
<html:option value= "2">DVD5</html:option>
<html:option value= "3">DVD9</html:option>
</html:select>
</td>
<td><html:text name="pd" property="gameCapacity" size="5"/></td>
<td>
<html:select name="pd" property="gameCopyright" >
<html:option value= "1">正版 </html:option>
<html:option value= "2">翻版</html:option>
</html:select>
</td>
<td><html:text name="pd" property="gamePrice" size="10"/></td>
<td><html:text name="pd" property="gameContent"/></td>
</tr>
</table>
<html:hidden property="method" value="doUpdateProduct"/>
<html:hidden name="pd" property="gameId" />
<html:hidden property="flag" value="<%= flag%>"/>
<html:hidden property="fieldname" value="<%= fieldname%>"/>
<html:hidden property="value" value="<%=value%>"/>
<html:submit property="submit" value="保存"></html:submit>
</html:form>
</body>
</html>
product_success.jsp頁面代碼:
<%@page pageEncoding="GBK" contentType="text/html; charset=GBK" %>
<%
String flag=(String)request.getAttribute("flag");
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>
</head>
<body>
操作成功!
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<a href="/game/addProductPage.do?method=doAddProductPage&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">繼續添加</a>
</body>
</html>
<%
String flag=(String)request.getAttribute("flag");
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>
</head>
<body>
操作成功!
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
<a href="/game/addProductPage.do?method=doAddProductPage&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">繼續添加</a>
</body>
</html>
product_failure.jsp頁面代碼:
<%@page pageEncoding="GBK" contentType="text/html; charset=GBK" %>
<%
String flag=(String)request.getAttribute("flag");
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>
</head>
<body>
操作失敗!
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
</body>
</html>
<%
String flag=(String)request.getAttribute("flag");
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>
</head>
<body>
操作失敗!
<a href="/game/returnProduct.do?method=doReturnProduct&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>">返回</a>
</body>
</html>
最後在tld文件夾中添加下列tld文件。
至此,整個項目基本編寫完了,運行tomcat,看看我們的項目的效果吧!
然後點擊“進入遊戲軟件管理單元”鏈接,主界面出現了。