HTTP Status 500 - Unable to compile class for JSP:这个
<%@pagecontentType="text/html;charset=gb2312"%><%@pageimport="java.sql.*"%><html><bod...
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=yjndx";
//pubs为你的数据库的
String user="sa";//输入你开通信里的数据库用户名
String password="sa";//输入你开通信里的数据库密码
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery("SELECT * FROM banjixinxi"); //注意这里的数据库表的名称把 xxxx修改为你的数据表
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%> <br>
您的第二个字段内容为:<%=rs.getString(2)%> <br>
您的第三个字段内容为:<%=rs.getString(3)%> <br>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
以上是源代码,用的是tomcat 7,myeclipse运行时就出现这样的问题:
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: 18 in the jsp file: /sqltest.jsp
String literal is not properly closed by a double-quote
15: 镇ㄧ殑绗簩涓瓧娈靛唴瀹逛负锛�%=rs.getString(2)%> <br>
16: 镇ㄧ殑绗笁涓瓧娈靛唴瀹逛负锛�%=rs.getString(3)%> <br>
17: <%}%>
18: <%out.print("鏁版嵁搴撴搷浣沧垚锷燂紝鎭枩浣�);%>
19: <%rs.close();
20: stmt.close();
21: conn.close();
<script type="text/javascript" src="/test_ssh/jquery-1.7.1.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理界面</title>
<script type="text/javascript">
function del(id){
$.get("/test_ssh/user/delUser?id=" + id,function(data){
if("success" == data.result){
alert("删除成功");
window.location.reload();
}else{
alert("删除失败");
} }); }
</script>
</head> 展开
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=yjndx";
//pubs为你的数据库的
String user="sa";//输入你开通信里的数据库用户名
String password="sa";//输入你开通信里的数据库密码
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery("SELECT * FROM banjixinxi"); //注意这里的数据库表的名称把 xxxx修改为你的数据表
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%> <br>
您的第二个字段内容为:<%=rs.getString(2)%> <br>
您的第三个字段内容为:<%=rs.getString(3)%> <br>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
以上是源代码,用的是tomcat 7,myeclipse运行时就出现这样的问题:
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: 18 in the jsp file: /sqltest.jsp
String literal is not properly closed by a double-quote
15: 镇ㄧ殑绗簩涓瓧娈靛唴瀹逛负锛�%=rs.getString(2)%> <br>
16: 镇ㄧ殑绗笁涓瓧娈靛唴瀹逛负锛�%=rs.getString(3)%> <br>
17: <%}%>
18: <%out.print("鏁版嵁搴撴搷浣沧垚锷燂紝鎭枩浣�);%>
19: <%rs.close();
20: stmt.close();
21: conn.close();
<script type="text/javascript" src="/test_ssh/jquery-1.7.1.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理界面</title>
<script type="text/javascript">
function del(id){
$.get("/test_ssh/user/delUser?id=" + id,function(data){
if("success" == data.result){
alert("删除成功");
window.location.reload();
}else{
alert("删除失败");
} }); }
</script>
</head> 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询