81,092
社区成员
发帖
与我相关
我的任务
分享
<body>
<img src="thumbs/9.jpg" width="179" height="100" alt="" onclick="show_id2('9')"/>
<script type="text/javascript" src="1.js"></script>
</body>
var tu1;
tu1 = 3;
function show_id2(str){
tu1 = str;
}
<body>
Connection conn=null;
PreparedStatement pstmt = null;
try {
Class.forName("com.mysql.jdbc.Driver");//加载JDBC驱动程序
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bbs","root","root");//连接MySQL数据库
}catch (ClassNotFoundException e) {
out.println("找不到驱动类");
} catch (SQLException e) {
out.println("连接MySQL数据库失败");
}
try{
Statement stmt = conn.createStatement();
String queryAll = "insert into user(id,username,password,email,sex) values(null,'candy','123','666','nan');";
int rs = stmt.executeUpdate(queryAll);
//获得所有记录
if(rs != 0)
{
out.println(tu1);
}
else
{
response.sendRedirect("No.jsp");
}
}catch (SQLException e) {
out.println("查询用户信息失败");
e.printStackTrace();
}
%>
</body>
var tu1;
tu1 = 3;
function show_id2(str){
tu1 = str;
window.location.href="2.jsp?tu1=1";
}
var tu1;
tu1 = 3;
function show_id2(str){
tu1 = str;
window.location.href="2.jsp?tu1=1";
}
[/quote]
你可以直接把js的变量设进去,参数名称可以自定义
window.location.href="2.jsp?aa="+tu1;
不跳转,你在js函数里面 设置断点打印一下(例如:alert("aaaa")),看有没有进到里面