J2EE学习笔记——MVC网上商城系统(二)(

Result.jsp:

 

<%@ page language="java" import="java.util.*,xuyan.model.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
      
   ArrayList al=(ArrayList)request.getAttribute("showresult");
  
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Result.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    
    <form >
    
   
    <div style="text-align: center">
        <div style="text-align: center">
            <table style="width: 578px; height: 76px; background-color: #ffff66;" border="2">
                <tr>
                    <td style="font-weight: bold; width: 100px; color: blue">
                        编号:</td>
                    <td style="font-weight: bold; width: 100px; color: blue">
                        名称:</td>
                    <td style="font-weight: bold; width: 100px; color: blue">
                        单价:</td>
                    <td style="font-weight: bold; width: 100px; color: blue">
                        数量:</td>
                </tr>
                <tr>
                <%
                 
                    for(int i=0;i<al.size();i++)
                    {
                   GoodsBean gb=(GoodsBean)al.get(i);
                        
                    
                   
                 %>
                    <td style="width: 100px; height: 48px;">
                  <%=gb.getGoodsID() %>
                    </td>
                    <td style="width: 100px; height: 48px;">
                  <%=gb.getGoodsName() %>
                    </td>
                    <td style="width: 100px; height: 48px;">
                 <%=gb.getGoodsPrice() %>
                    </td>
                    <td style="width: 100px; height: 48px;">
                        <div style="text-align: center">
                            <table style="width: 144px; height: 28px">
                                <tr>
                                    <td style="width: 63px">
                                       <input type="text" name="num2"></td>
                                    <td style="width: 100px">
                                    <a href="ShopServlet?flag=DeleteGoods">删除</a>
                                       </td>
                                    <td style="width: 100px">
                                         <a href="ShopServlet">查看</a>
                                        </td>
                                </tr>
                            </table>
                        </div>
                        
                       
                    </td>
                </tr>
                <%
                }
                
                 %>
              
                <tr>
                    <td style="width: 100px">
                    </td>
                    <td style="width: 100px">
                        <input  type="button" value="删除全部书籍" /></td>
                    <td style="width: 100px">
                         <input type="submit" value=更改数量></td>
                    <td style="width: 100px">
                    </td>
                </tr>
            </table>
        </div>
    </div>
    
     <div style="text-align: center">
        <table border="2" style="width: 574px; height: 23px">
            <tr>
                <td style="font-weight: bold; width: 100px; color: red">
                                                    您共选择了价值()元的商品
                </td>
                <td style="width: 100px">
                    <input id="Button5" style="width: 101px" type="button" value="下一步" /></td>
            </tr>
        </table>
    </div>
    
    </form>
    
  </body>
</html>


 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
J2EE开发中,我们经常需要对字符串进行编码,以便在不同的系统之间传输数据时,能够正确地处理特殊字符。其中,URLEncoder.encode(String, enc)是一种常用的编码方式。 URLEncoder.encode()方法的作用是将指定的字符串进行编码,以便在URL中传输。它的语法如下: ``` public static String encode(String s, String enc) throws UnsupportedEncodingException ``` 其中,参数s是要编码的字符串,参数enc是指定字符集的名称,如果不指定,默认为UTF-8。 该方法的返回值是一个编码后的字符串。 例如,如果要将字符串“Hello World!”编码为UTF-8格式的字符串,可以使用以下代码: ``` String encodedStr = URLEncoder.encode("Hello World!", "UTF-8"); System.out.println(encodedStr); ``` 执行该代码后,输出结果为: ``` Hello+World%21 ``` 可以看到,空格被编码为“+”号,感叹号被编码为“%21”。 需要注意的是,如果字符串中包含特殊字符,如“&”、“=”等,也需要进行编码,否则在URL传输时会出现错误。例如,如果要将字符串“name=张三&age=18”编码为UTF-8格式的字符串,可以使用以下代码: ``` String encodedStr = URLEncoder.encode("name=张三&age=18", "UTF-8"); System.out.println(encodedStr); ``` 执行该代码后,输出结果为: ``` name%3D%E5%BC%A0%E4%B8%89%26age%3D18 ``` 可以看到,等号被编码为“%3D”,中文字符被编码为UTF-8格式的字符串。 总之,URLEncoder.encode()方法是J2EE开发中常用的编码方式,可以有效地处理特殊字符,确保数据在不同系统之间的传输正确无误。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值