我再发一遍,刚才的代码没写上去
我采用了你说的方法为什么从数据库读出让他显示有问题呢??下面是我写的程序
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" %>
<%request.setCharacterEncoding("UTF-8");%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
jsp2
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<%
String title = request.getParameter("title");
out.println(title);
%>
<%
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/xinwen?useUnicode=true&characterEncoding=UTF-8","root","root");
Statement sm = con.createStatement();
ResultSet rs =sm.executeQuery("select * from news where id=153");
if(rs.next()){
title = rs.getString("title");
out.println(title);
}
}
catch(SQLException ex){
}
catch(ClassNotFoundException ex1){
}
%>
</h1>
</body>
操作系统是WIN2000SERVER版的,开发工具JBUILDER,服务器TOMCAT请指正