JSP/JAVA

JAVA SERVER PAGES

最近学校实习课,我做了个博客,现在把其中发现的问题和解决方法给大家共享下

 

1》验证码:产生的随机数要放到session里

2》用select top5 * from art 出错 游标状态无效:去除括号里的
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);


3》数据库连接池:虽然包含了<%@include file="conn.jsp"%>但还是要在文件里声明
<%! ResultSet rs=null;%>
<%! Statement stmt=null;%>
否则会出现 rs/stmt cannot be resolved


4》中文写入ACCESS数据库为什么是 ??:  只要加
String title=request.getParameter("title");
title=new String(title.getBytes("ISO-8859-1"));
String neirong=request.getParameter("neirong");
neirong=new String(neirong.getBytes("ISO-8859-1"));

就OK了

5》出现错误 
rs.last() An exception occurred processing JSP page
: stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE  能让记录集能够前后移动


6》错误为:
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 16 in the jsp file: /biyesheji/nixie/addx.jsp
String literal is not properly closed by a double-quote
13: String eno=request.getParameter("eno");
14: String wdate=request.getParameter("wdate");
15: String ano=request.getParameter("ano");
16: String sql="insert into pageinfo(num,typeid,seno,eno,wdate,ano)
17: values('"+num+"','"+typeid+"','"+seno+"','"+eno+"','"+wdate+"','"+ano+"') ";
18: addx.executeUpdate(sql);
19: try{ sqlBean db =new sqlBean();


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


解决方法:

一行代码可以换行写,一个String的内容是不能换几行写的,写成
String sql="insert into pageinfo(num,typeid,seno,eno,wdate,ano)" +
"values('"+num+"','"+typeid+"','"+seno+"','"+eno+"','"+wdate+"','"+ano+"') ";

posted on 2009-06-26 18:15 C鸡鸡 阅读(412) 评论(0)  编辑  收藏 所属分类: JSP


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

Blog Stats

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

友情链接

学习网站

搜索

最新评论

阅读排行榜

评论排行榜