`
primer_2004
  • 浏览: 124005 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

struts+spring+hibernate的web应用(4.4)

    博客分类:
  • Java
阅读更多
接着就是写资源文件了。
在com.game.resources包中添加ApplicationResourcesProducts.properties文件。如果你的eclipse中有Properties Editor这个插件,就可以用Properties Editor打开资源文件进行编写,省去了用命令行转换格式的麻烦。配置内容如下:
  1. errors.required={0}不能为空.   
  2. errors.minlength={0}不能小于 {1} 个字符.   
  3. errors.maxlength={0}不能大于 {1} 个字符.   
  4. errors.invalid={0}输入格式不对.   
  5. errors.byte={0}必须为字节.   
  6. errors.short={0}必须为短整型.   
  7. errors.integer={0}必须为整型.   
  8. errors.long={0}必须为长整型.   
  9. errors.float={0}必须为浮点型.   
  10. errors.double={0}必须为双精度型.   
  11. errors.date={0}不是一个正确的日期或格式不对.   
  12. errors.range={0} is not in the range {1} through {2}.   
  13. errors.creditcard={0} is not a valid credit card number.   
  14. errors.email={0}不是一个有效的email地址.   
  15.   
  16. errors.gameNameCn=游戏中文名称   
  17. errors.gameNameEn=游戏英文名称   
  18. errors.gameCapacity=碟数   
  19. errors.gamePrice=价格  
 
需要注意的是
 ssh3.jpg这一节是不能省去的。
 
接下来就是写页面文件了。在products文件夹中添加如下页面。
index.jsp页面代码:
  1. <%@ page contentType="text/html;charset=GBK" language="java" %>  
  2.   
  3. <html>  
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>  
  6. <title>游戏软件管理系统title>  
  7. head>  
  8. <body>  
  9.   
  10. <a href="/game/getProducts.do?method=doGetProducts&&flag=1">进入游戏软件管理单元a>  
  11. body>  
  12. html>  

products.jsp页面代码:

  1. <%@page pageEncoding="GBK" contentType="text/html; charset=GBK" import="com.game.commons.Pager;"%>  
  2. <%@ taglib uri="struts-html" prefix="html" %>  
  3. <%@ taglib uri="struts-logic" prefix="logic" %>  
  4. <%@ taglib uri="struts-bean" prefix="bean" %>  
  5. <%   
  6. String flag=(String)request.getAttribute("flag");   
  7. String totalRows=(String)request.getAttribute("totalRows");   
  8. String fieldname="";   
  9. String value="";   
  10. if(flag.equals("2")){   
  11.     fieldname=(String)request.getAttribute("fieldname");   
  12.     value=(String)request.getAttribute("value");   
  13. }   
  14. %>  
  15. <html>  
  16. <head>  
  17. <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>  
  18. <title>title>  
  19. <script language = "JavaScript">  
  20. function btnQuery() {   
  21.     if(myfm.value.value=="")   
  22.     {       
  23.         alert("请输入查询关键字!");   
  24.     }else{   
  25.         window.location.href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname="+myfm.fieldname.value+"&&value="+myfm.value.value;   
  26.      }   
  27.  }   
  28.  script>  
  29. head>  
  30. <body>  
  31. <form  name="myfm" method="post">  
  32. <table border="1">  
  33. <tr>  
  34. <td>  
  35. <a href="/game/getProducts.do?method=doGetProducts&&flag=1">察看所有记录a>  
  36.       
  37. td>  
  38. <td>  
  39. <a href="/game/addProductPage.do?method=doAddProductPage&&flag=<!---->&&fieldname=<!---->&&value=<!---->">添加a>  
  40.       
  41. td>  
  42. <td>  
  43.     <select name="fieldname" >  
  44.         <option value="gameNameCn">中文名称option>  
  45.         <option value="gameNameEn">英文名称option>  
  46.         <option value="gameCapacity">碟数option>  
  47.         <option value="gameVersion">版本option>  
  48.         <option value="gameMedia">介质option>  
  49.         <option value="gameCopyright">版权option>  
  50.     select>  
  51.     <input value="" name="value"  />  
  52.   
  53. <a href="#" onclick="btnQuery()">查询a>  
  54. td>  
  55. tr>  
  56. table>  
  57. <br>  
  58. <br>  
  59.      
  60. <table border="1">  
  61.     <tr>  
  62.         <td>游戏中文名称td>  
  63.         <td>游戏英文名称td>  
  64.         <td>软件版本td>  
  65.         <td>软件介质td>  
  66.         <td>碟数td>  
  67.         <td>版权td>  
  68.         <td>价格(元)td>  
  69.         <td>攻略td>  
  70.     tr>  
  71.     <logic:iterate id="pd" name="productsList">  
  72.     <tr>  
  73.         <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>  
  74.         <td><bean:write name="pd" property="gameNameEn"/>td>  
  75.         <td>  
  76.             <logic:equal name="pd" property="gameVersion" value="1">  
  77.                 中文版   
  78.             logic:equal>  
  79.             <logic:equal name="pd" property="gameVersion" value="2">  
  80.                 英文版   
  81.             logic:equal>  
  82.         td>  
  83.         <td>  
  84.             <logic:equal name="pd" property="gameMedia" value="1">  
  85.                 CD   
  86.             logic:equal>  
  87.             <logic:equal name="pd" property="gameMedia" value="2">  
  88.                 DVD5   
  89.             logic:equal>  
  90.             <logic:equal name="pd" property="gameMedia" value="3">  
  91.                 DVD9   
  92.             logic:equal>  
  93.         td>  
  94.         <td><bean:write name="pd" property="gameCapacity"/>td>  
  95.         <td>  
  96.             <logic:equal name="pd" property="gameCopyright" value="1">  
  97.                 正版   
  98.             logic:equal>  
  99.             <logic:equal name="pd" property="gameCopyright" value="2">  
  100.                 翻版   
  101.             logic:equal>  
  102.         td>  
  103.         <td><bean:write name="pd" property="gamePrice"/>td>  
  104.         <td><bean:write name="pd" property="gameContent"/>td>  
  105.     tr>  
  106.     logic:iterate>  
  107.     <tr>  
  108.         <%if(flag.equals("1")){%>  
  109.             <td colspan="8" align="right" class="head">  
  110.                 共有<%=totalRows%>条记录       
  111.                 第<bean:write name="PAGER" property="currentPage"/>页    
  112.                 共<bean:write name="PAGER" property="totalPages"/>页    
  113.                 <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=first" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">首页html:link>  
  114.                 <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=previous" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">上一页html:link>  
  115.                 <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=next" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">下一页html:link>  
  116.                 <html:link action="/getProducts.do?method=doGetProducts&&flag=1&&pagerMethod=last" paramName="PAGER" paramProperty="currentPage" paramId="currentPage">尾页html:link>  
  117.             td>       
  118.         <%}else if(flag.equals("2")){%>  
  119.         <% Pager pager=(Pager)request.getAttribute("PAGER");%>  
  120.             <td colspan="8" align="right" class="head">  
  121.                 共有<%=totalRows%>条记录       
  122.                 第<bean:write name="PAGER" property="currentPage"/>页    
  123.                 共<bean:write name="PAGER" property="totalPages"/>页    
  124.                 <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<!---->&&value=<!---->&&pagerMethod=first&¤tPage=<!---->" >首页a>  
  125.                 <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<!---->&&value=<!---->&&pagerMethod=previous&¤tPage=<!---->" >上一页a>  
  126.                 <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<!---->&&value=<!---->&&pagerMethod=next&¤tPage=<!---->" >下一页a>  
  127.                 <a href="/game/queryProducts.do?method=doQueryProduct&&flag=2&&fieldname=<!---->&&value=<!---->&&pagerMethod=last&¤tPage=<!---->" >尾页a>  
  128.                    
  129.             td>       
  130.         <%}%>  
  131.     tr>  
  132. table>  
  133. form>  
  134. body>  
  135. html>  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics