1. html页面不显示中文
在html代码最前面加上
<%@ page language="java" contentType="text/html; charset=gbk"
pageEncoding="gbk"%>
//gbk是一种编码,支持中文,其他支持中文的编码有 gb2312,utf-8.
2.报错
ResultSet cannot be resolved to a type
Statement cannot be resolved to a type
Connection cannot be resolved to a type
DriverManager cannot be resolved
SQLException cannot be resolved to a type
需要引入含 Class.forName方法
<%@ page import="java.sql.*" %>
3.无法找到mysql的Jdbc驱动
mysql-connector-java-5.1.18-bin.jar
jar文件解压后的文件夹, 放到tomcat的 lib 文件夹中
4.onclick="loadTest("1234")" 中参数1234无法传递给方法loadTest;
写法错误,应为 onclick="loadTest("1234");" 在("1234") 后加上 分号 ;
5.使用超链接传递参数id
url="http://localhost:8080/Produce2/Test.jsp?id="+id;
在接收参数id 的Test.jsp 中需要对 id进行类型转换
如:
String task = request.getParameter("id"); // 把传过来的 id内容转换为 字符串,并赋值给task
int myid = Integer.parseInt(request.getParameter("id")); // 把传过来的 id内容转换为 整型,并赋值给myid