第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

亂碼問(wèn)題?

怎么加了req.setCharacterEncoding("UTF-8");

斷點(diǎn)看到的數(shù)據(jù)依然是亂碼 老師求解


@SuppressWarnings("serial")
public class ListServlet extends HttpServlet{
?? ?@Override
?? ?protected void doGet(HttpServletRequest req, HttpServletResponse resp)
?? ??? ??? ?throws ServletException, IOException {
?? ??? ?try {
?? ??? ??? ?req.setCharacterEncoding("UTF-8");
?? ??? ??? ?String command=req.getParameter("command");
?? ??? ??? ?String description=req.getParameter("description");
?? ??? ??? ?Class.forName("com.mysql.jdbc.Driver");
?? ??? ??? ?Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/micro_message","root","1234");
?? ??? ??? ?StringBuilder sql=new StringBuilder("select ID,COMMAND,DESCRIPTION,CONTENT from MESSAGE where 1=1 ");
?? ??? ??? ?List<String> paramList=new ArrayList<String>();
?? ??? ??? ?
?? ??? ??? ?if(null!=command&&!"".equals(command.trim())){
?? ??? ??? ??? ?sql.append("and COMMAND=?");
?? ??? ??? ??? ?paramList.add(command);
?? ??? ??? ?}
?? ??? ??? ?if(null!=description&&!"".equals(description.trim())){
?? ??? ??? ??? ?sql.append("and DESCRIPTION like '%' ? '%'");
?? ??? ??? ??? ?paramList.add(description);
?? ??? ??? ?}
?? ??? ??? ?PreparedStatement preparedStatement=conn.prepareStatement(sql.toString());
?? ??? ??? ?for (int i=0;i<paramList.size();i++) {
?? ??? ??? ??? ?System.out.println(paramList.get(i));
?? ??? ??? ??? ?preparedStatement.setString(i+1, paramList.get(i));
?? ??? ??? ?}

?? ??? ??? ?ResultSet rs=preparedStatement.executeQuery();
?? ??? ??? ?List<Message> messageList=new ArrayList<Message>();
?? ??? ??? ?while(rs.next()){
?? ??? ??? ??? ?Message message=new Message();
?? ??? ??? ??? ?messageList.add(message);
?? ??? ??? ??? ?message.setId(rs.getString("ID"));
?? ??? ??? ??? ?message.setCommand(rs.getString("COMMAND"));
?? ??? ??? ??? ?message.setContent(rs.getString("CONTENT"));
?? ??? ??? ??? ?message.setDescription(rs.getString("DESCRIPTION"));
?? ??? ??? ?}
?? ??? ??? ?req.setAttribute("messageList", messageList);
?? ??? ?} catch (ClassNotFoundException e) {
?? ??? ??? ?e.printStackTrace();
?? ??? ?} catch (SQLException e) {
?? ??? ??? ?e.printStackTrace();
?? ??? ?}
?? ??? ?req.getRequestDispatcher("/WEB-INF/jsp/back/List.jsp").forward(req, resp);
?? ?}
?? ?
?? ?@Override
?? ?protected void doPost(HttpServletRequest req, HttpServletResponse resp)
?? ??? ??? ?throws ServletException, IOException {
?? ??? ?super.doGet(req, resp);
?? ?}



==============================================

jsp頁(yè)面代碼



<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
?? ?<head>
?? ??? ?<title>內(nèi)容列表頁(yè)面</title>
?? ??? ?<link href="<%=basePath %>/resources/css/all.css" rel="stylesheet" type="text/css" />
?? ?</head>
?? ?<body style="background: #e1e9eb;">
?? ??? ?<form action="<%=basePath %>List.action" id="mainForm" method="get">
?? ??? ??? ?<div class="right">
?? ??? ??? ??? ?<div class="current">當(dāng)前位置:<a href="javascript:void(0)" style="color:#6E6E6E;">內(nèi)容管理</a> &gt; 內(nèi)容列表</div>
?? ??? ??? ??? ?<div class="rightCont">
?? ??? ??? ??? ??? ?<p class="g_title fix">內(nèi)容列表 <a class="btn03" href="#">新 增</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="btn03" href="#">刪 除</a></p>
?? ??? ??? ??? ??? ?<table class="tab1">
?? ??? ??? ??? ??? ??? ?<tbody>
?? ??? ??? ??? ??? ??? ??? ?<tr>
?? ??? ??? ??? ??? ??? ??? ??? ?<td width="90" align="right">指令名稱:</td>
?? ??? ??? ??? ??? ??? ??? ??? ?<td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<input name="command" type="text" class="allInput" value=""/>
?? ??? ??? ??? ??? ??? ??? ??? ?</td>
?? ??? ??? ??? ??? ??? ??? ??? ?<td width="90" align="right">描述:</td>
?? ??? ??? ??? ??? ??? ??? ??? ?<td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<input name="description" type="text" class="allInput" value=""/>
?? ??? ??? ??? ??? ??? ??? ??? ?</td>
?? ???????????????????????????? <td width="85" align="right"><input type="submit" class="tabSub" value="查 詢" /></td>
?? ?????? ??? ??? ??? ??? ??? ?</tr>
?? ??? ??? ??? ??? ??? ?</tbody>
?? ??? ??? ??? ??? ?</table>
?? ??? ??? ??? ??? ?<div class="zixun fix">
?? ??? ??? ??? ??? ??? ?<table class="tab2" width="100%">
?? ??? ??? ??? ??? ??? ??? ?<tbody>
?? ??? ??? ??? ??? ??? ??? ??? ?<tr>
?? ??? ??? ??? ??? ??? ??? ??? ???? <th><input type="checkbox" id="all" onclick="#"/></th>
?? ??? ??? ??? ??? ??? ??? ??? ???? <th>序號(hào)</th>
?? ??? ??? ??? ??? ??? ??? ??? ???? <th>指令名稱</th>
?? ??? ??? ??? ??? ??? ??? ??? ???? <th>描述</th>
?? ??? ??? ??? ??? ??? ??? ??? ???? <th>操作</th>
?? ??? ??? ??? ??? ??? ??? ??? ?</tr>
?? ??? ??? ??? ??? ??? ??? ??? ?<c:forEach? items="${messageList }" var="message" varStatus="status">
?? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ?? <tr <c:if test="${status.index%2!=0 }">style='background-color:#ECF6EE;'</c:if> >
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<td><input type="checkbox" /></td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<td>${status.index+1}</td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<td>${message.command }</td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<td>${message.description }</td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?<td>
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?<a href="#">修改</a>&nbsp;&nbsp;&nbsp;
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?<a href="#">刪除</a>
?? ??? ??? ??? ??? ??? ??? ??? ??? ?</td>
?? ??? ??? ??? ??? ??? ??? ??? ?? </tr>
?? ??? ??? ??? ??? ??? ??? ??? ?</c:forEach>

?? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ?</tbody>
?? ??? ??? ??? ??? ??? ?</table>
?? ??? ??? ??? ??? ??? ?<div class='page fix'>
?? ??? ??? ??? ??? ??? ??? ?共 <b>4</b> 條
?? ??? ??? ??? ??? ??? ??? ?<a href='###' class='first'>首頁(yè)</a>
?? ??? ??? ??? ??? ??? ??? ?<a href='###' class='pre'>上一頁(yè)</a>
?? ??? ??? ??? ??? ??? ??? ?當(dāng)前第<span>1/1</span>頁(yè)
?? ??? ??? ??? ??? ??? ??? ?<a href='###' class='next'>下一頁(yè)</a>
?? ??? ??? ??? ??? ??? ??? ?<a href='###' class='last'>末頁(yè)</a>
?? ??? ??? ??? ??? ??? ??? ?跳至&nbsp;<input type='text' value='1' class='allInput w28' />&nbsp;頁(yè)&nbsp;
?? ??? ??? ??? ??? ??? ??? ?<a href='###' class='go'>GO</a>
?? ??? ??? ??? ??? ??? ?</div>
?? ??? ??? ??? ??? ?</div>
?? ??? ??? ??? ?</div>
?? ??? ??? ?</div>
?? ???? </form>
?? ?</body>
</html>

正在回答

1 回答

你的表單使用的get方式傳遞參數(shù)的,get是把參數(shù)放到URL路徑后面提交參數(shù)的,解決方法:

修改tomcat的conf目錄下的server.xml文件中的Connector標(biāo)簽,末尾加入 URIEncoding="utg-8";

如果還是不行的話,你試著把表單提交方式改為method="post",試一下;

如果還是不行的話,項(xiàng)目--右鍵-屬性-資源-文本編碼方式--UTF-8;



0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
通過(guò)自動(dòng)回復(fù)機(jī)器人學(xué)Mybatis---基礎(chǔ)版
  • 參與學(xué)習(xí)       107413    人
  • 解答問(wèn)題       830    個(gè)

微信公眾號(hào)自動(dòng)回復(fù)功能學(xué)習(xí)Mybatis,基礎(chǔ)教程加案例實(shí)戰(zhàn)方式學(xué)習(xí)

進(jìn)入課程
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)