struts+spring+hibernate的web应用 Web层代码编写(2)

接着就是写资源文件了。

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

<o:p></o:p>

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=价格


 

需要注意的是

<o:p> ssh3.jpg</o:p>

这一节是不能省去的。

<o:p> </o:p>

接下来就是写页面文件了。在products文件夹中添加如下页面。

<o:p> </o:p>

index.jsp页面代码:

<o:p></o:p>

<% @ page contentType="text/html;charset=GBK" language="java"  %>

< html >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=GBK" />
< title > 游戏软件管理系统 </ title >
</ head >
< body >

< href ="/game/getProducts.do?method=doGetProducts&&flag=1" > 进入游戏软件管理单元 </ a >
</ body >
</ html >

 

 

<o:p> </o:p>

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 >
< href ="/game/getProducts.do?method=doGetProducts&&flag=1" > 察看所有记录 </ a >
&nbsp;&nbsp;&nbsp;
</ td >
< td >
< href ="/game/addProductPage.do?method=doAddProductPage&&flag=<%= flag%>&&fieldname=<%=fieldname%>&&value=<%= value%>" > 添加 </ a >
&nbsp;&nbsp;&nbsp;
</ 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"    />

< 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 >< 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值