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

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

編譯器未報(bào)錯(cuò),command,description列內(nèi)容全是問號(hào)

http://img1.sycdn.imooc.com//58aaa5640001c58c13440392.jpg

這是servlet:

package servlet;


import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.ArrayList;

import java.util.List;


import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import org.apache.catalina.valves.JDBCAccessLogValve;


import dblink.DBHelper;


import beans.Message;



/**

?*?

?* 列表頁面初始化控制

?*

?*/

@SuppressWarnings("serial")

public class ListServlet extends HttpServlet{

@Override

protected void doGet(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {

try {

new DBHelper();

Connection conn=DBHelper.getConnection();

String sql="select ID,COMMAND,DESCRIPTION,CONTENT from message";

PreparedStatement statement=conn.prepareStatement(sql);

ResultSet rs=statement.executeQuery();

List<Message> messagelist=new ArrayList<Message>();

while(rs.next()){

Message message=new Message();

message.setId(rs.getString("ID"));

message.setCommand(rs.getString("COMMAND"));

message.setDescription(rs.getString("DESCRIPTION"));

message.setContent(rs.getString("CONTENT"));

messagelist.add(message);

}

req.setAttribute("messagelist",messagelist);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

req.getRequestDispatcher("/WEB-INF/jsp/back/list.jsp").forward(req, resp);

}

@Override

protected void doPost(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {

this.doGet(req, resp);

}

}

這是list.jsp:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ 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>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta http-equiv="X-UA-Compatible"content="IE=9; IE=8; IE=7; IE=EDGE" />

<title>內(nèi)容列表頁面</title>

<link href="<%= basePath %>resources/css/all.css" rel="stylesheet" type="text/css" />

</head>

<body style="background: #e1e9eb;">

<form action="" id="mainForm" method="post">

<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">演示字段1:</td>

<td>

<input type="text" class="allInput" value=""/>

</td>

<td width="90" align="right">演示字段2:</td>

<td>

<input 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'>首頁</a>

<a href='###' class='pre'>上一頁</a>

當(dāng)前第<span>1/1</span>頁

<a href='###' class='next'>下一頁</a>

<a href='###' class='last'>末頁</a>

跳至&nbsp;<input type='text' value='1' class='allInput w28' />&nbsp;頁&nbsp;

<a href='###' class='go'>GO</a>

</div>

</div>

</div>

</div>

? ?</form>

</body>

</html>

這是數(shù)據(jù)庫連接工具類:

package dblink;


import java.sql.Connection;

import java.sql.DriverManager;


public class DBHelper {

? ?

private static final String DRIVER = "com.mysql.jdbc.Driver";?

private static final String URL="jdbc:mysql://localhost:3306/we_chart?useUnicode=true&characterEncoding=UTF-8";?

private static final String USERNAME="root";

private static final String PASSWORD="490321";//

? ??

private static Connection conn=null;

//獲得驅(qū)動(dòng)

static?

{

try

{

Class.forName(DRIVER);

}

catch(Exception ex)

{

ex.printStackTrace();

}

}


public static Connection getConnection() throws Exception

{

if(conn==null)

{

conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);

return conn;

}

return conn;

}

}


正在回答

3 回答

我知道了跟著老師把.html改成.jsp
但是沒有加
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>

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

控制臺(tái)有沒有報(bào)錯(cuò)?(數(shù)據(jù)庫能連接上嗎)

jsp打印輸出一下看能不能獲取到messageList具體的值。

代碼看不出有什么問題

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

來個(gè)不被占用的昵稱

樓上說的有道理,在servlet的doGet()加上req.setCharacterEncoding("utf-8")
2017-02-20 回復(fù) 有任何疑惑可以回復(fù)我~
#2

kenny5730 提問者

控制臺(tái)沒有報(bào)錯(cuò),SQL語句在數(shù)據(jù)庫試過了沒問題
2017-02-21 回復(fù) 有任何疑惑可以回復(fù)我~

加上req.setEncoding(utf-8)

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

qq__3590

不對,是req.setCharacterEncoding("utf-8")
2017-02-20 回復(fù) 有任何疑惑可以回復(fù)我~
#2

kenny5730 提問者 回復(fù) qq__3590

加了以后還是老樣子
2017-02-21 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

編譯器未報(bào)錯(cuò),command,description列內(nèi)容全是問號(hào)

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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