关于web项目部署到云平台上get方式进行参数传输是中文乱码的问题

关于web项目部署到云平台上get方式进行参数传输是中文乱码的问题

系统默认为ISO的那个

中文utf-8或者GBK均可以

样例传输通过


a.jsp

数据来源页

<%@ page language="java" contentType="text/html; charset=utf-8"%>

<form action="lookFriends.jsp" class="smart-form">										
											<%
											//DB mysql = new DB();
											// String userName = mysql.returnLogin(request);
											
		%>
											
											<fieldset>										
											<!--  	<section>
													<label class="label">New Book Number</label>
													<label class="input">
														<input type="text" name="idbookinformation" value="" class="input-sm">
													</label>
												  	</section>-->		
											<!--  	<section>-->
													<label class="label">Book ISBN(PK)</label>
													<label class="input">
														<input type="text" name="ISBNnum" value="" class="input-sm">
													</label>
											<!--  	</section>-->		
											<!--  	<section>-->
													<label class="label">Book Title</label>
													<label class="input">
														<input type="text" name="newbookname" value="" class="input-sm" >
													</label>
											<!--  	</section>-->
																				
									<!--  	<section>-->
													<label class="label">Author ID(FK)</label>
													<label class="input">
														<input type="text" name="author" value="" class="input-sm">
													</label>
											<!--  	</section>-->
												
										<!--  	<section>-->
													<label class="label">Publisher</label>
													<label class="input">
														<input type="text" name="publisher" value="" class="input-sm">
													</label>
												<!--  	</section>-->
												
											<!--  	<section>-->
													<label class="label">Publish Date</label>
													<label class="input">
														<input type="text" name="date" value="" class="input-sm">
													</label>
												<!--  	</section>-->
												
									<!--  	<section>-->
													<label class="label">Price</label>
													<label class="input">
														<input type="text" name="price" value="" class="input-sm">
													</label>
											<!--  	</section>-->
											
											</fieldset>
																							
											
											<td colspan= "2" align="center">
												
												<input type="submit" value="finish" size="12">
												<input type="reset" value="clear" size="12">
											</td>
											
										</form>
										
									</div>


接受数据b.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
   pageEncoding="ISO-8859-1"%>



<table class="table table-bordered">
           <thead>
            <tr>
           <!--   <th>Book Number</th> -->
             <th> ISBN(PK)</th>
             <th> Title</th>
             <th> Author(ID)</th>
             <th> Publisher</th>
             <th> PublishDate</th>
             <th> Price</th>
            </tr>
           </thead>
           <tbody>
           <%
           DB mysql = new DB();
           String fri;
           
           String userName = mysql.returnLogin(request);
           
           String ISBNnumupdate = request.getParameter("ISBNnumupdate");
           if(ISBNnumupdate != null)
           {
            fri = mysql.deleteFri(request,userName,ISBNnumupdate);
            //System.out.println("1");
           }
           
           String ISBNdelete = request.getParameter("ISBNdelete");
           if(ISBNdelete != null)
            fri = mysql.deleteFri(request,userName,ISBNdelete);
           
           String newbookname=request.getParameter("newbookname");
           //if(newbookname != null)
           // newbookname =  new String(request.getParameter("newbookname").getBytes("ISO-8859-1"),"utf-8");
           //String newbookname =  new String(request.getParameter("newbookname").getBytes("ISO-8859-1"),"GB2312");
           //System.out.println(newbookname);
           //newbookname=new String(newbookname.getBytes("iso-8859-1"),"GB18030");
           String price = request.getParameter("price");
           String date = request.getParameter("date");
           String author =request.getParameter("author");
           String publisher =request.getParameter("publisher");
           //if(publisher != null)
           // publisher = new String(request.getParameter("publisher").getBytes("ISO-8859-1"),"utf-8");
           //publisher=new String(publisher.getBytes("iso-8859-1"),"GB18030");
           String ISBN =request.getParameter("ISBNnum");
           //String Number =request.getParameter("idbookinformation");
           String Number = ISBN;
           //System.out.println(ISBN);
           if(ISBN != null)
            fri = mysql.insertFri(request, userName, newbookname, price, date, author, publisher,ISBN,Number);
           
           String newbookname1=request.getParameter("newbookname1");
           //if(newbookname1 != null)
           // newbookname1 =  new String(request.getParameter("newbookname1").getBytes("ISO-8859-1"),"utf-8");
           //newbookname=new String(newbookname.getBytes("iso-8859-1"),"GB18030");
           String price1 = request.getParameter("price1");
           String date1 = request.getParameter("date1");
           String author1 =request.getParameter("author1");
           String publisher1 =request.getParameter("publisher1");
           //if(publisher1 != null)
           // publisher1 = new String(request.getParameter("publisher1").getBytes("ISO-8859-1"),"utf-8");
           //publisher1=new String(publisher1.getBytes("GB18030"),"utf-8");
           String ISBN1 =request.getParameter("ISBNnumupdate");
           //String Number1 =request.getParameter("idbookinformation1");
           String Number1 = ISBN1;
           //System.out.println(ISBN);
           if(newbookname1 != null)
            fri = mysql.insertFri(request, userName, newbookname1, price1, date1, author1, publisher1,ISBN1,Number1);
           
           
           DB mysql1 = new DB();
           String userName1 = mysql.returnLogin(request);
           
           ResultSet rs = mysql.selectFriAll(request, userName1);
           String fri1 = mysql.myFriends345(request,userName1);
           ArrayList friends= (ArrayList)session.getAttribute("friends345");
           //System.out.println("1");
           if(friends == null|| friends.size() == 0){
           %>
           <h1>书籍库中未有书籍</h1>
           <%
           }else{
            for(int i=friends.size()-1;i>=0;i--)
            {
             MyFriBean ff =(MyFriBean)friends.get(i);
            
           %>
           
             <tr>
           <!--  <th><%=ff.getNumber()%></th>  -->  
             <th><%=ff.getISBN()%></th>
              <th><a href="domain.jsp?ISBN=<%=ff.getISBN()%>"><%=ff.getName()%></a></th> 
             
             <th><%=ff.getauthor()%></th>
             <th><%=ff.getpublisher()%></th>
             <th><%=ff.getdate()%></th>
             <th><%=ff.getprice()%></th>
            </tr>
           <%
            }
           }
           %>
           
           </tbody>
          </table>
          
 


这样数据传输的时候具有有效性



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值