错误提示页面显示
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 15 in the jsp file: /tan/register-result.jsp
String literal is not properly closed by a double-quote
1: <%@ page contentType="charset=GBK" import="java.sql.*"%>
2: <%
3:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:467)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
我的代码是
<%@ page contentType="charset=GBK" import="java.sql.*"%>
<%
String user = request.getParameter("username");
String pass = request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://url/javaee", "user",
"pass");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from users ");
while (rs.next()) {
if (rs.getString("username").equals(user)) {
out.print("请重新注册");
out.print("用户名已存在");
}
else
{
stmt.executeUpdate("insert into users (username,password)
values ("user","pass")");
out.println("登录成功");
}
}
%>
求大神指导,已经困惑两天了,久久不得解。。。
------解决方案--------------------
如果这是你的源码的话,
stmt.executeUpdate("insert into users (username,password)
values ("user","pass")");
你这段代码没有报错吗?
------解决方案--------------------
------解决方案--------------------
固定值的
stmt.executeUpdate("insert into users (username,password) values (user,pass)");
估计你想要的效果是这个
stmt.executeUpdate("insert into users (username,password) values ("+user+","+pass+")");
------解决方案--------------------
你截个图呗,你说还报,我啥也不知道,怎么帮你啊
------解决方案--------------------
------解决方案--------------------
请确认你没删那两个变量
------解决方案--------------------
<%@ page contentType="charset=GBK" import="java.sql.*"%>
<%
String user = request.getParameter("username");
String pass = request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://url/javaee", "user",
"pass");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from users ");
while (rs.next()) {
if (rs.getString("username").equals(user)) {
out.print("请重新注册");
out.print("用户名已存在");
}
else
{
stmt.executeUpdate("insert into users (username,password) values ("+user+","+pass+")");
out.println("登录成功");
}
}
%>
我这不报错,你拿这个试试吧