还有这里的分
http://community.csdn.net/Expert/topic/3320/3320866.xml?temp=.5787165
http://community.csdn.net/Expert/topic/3320/3320866.xml?temp=.5787165
解决方案 »
- 利用axis2生成客户端stub类,在WEB应用程序调用报类找不到的错误
- tomcat显示问题
- 新手:请教如何注销?
- NullPointerException异常,代码如下!
- 在WEBSPHERE里面如何部署使用JSTL
- 请教高手,谁能给我解释清楚beans,javabean,EJB之间的区别???
- 用strut的<logic:iterate標簽循環輪出若幹行,要控制第一行的單元格顏色怎麼做?
- linux 下如何进行调试, System.out.print打印到那里去了,麻烦各位老大了!
- 通过图片点击在text中增加数字的问题
- php代码,如何修改成html,脱离php环境运行
- 大虾们,救命啊!。。。有分
- JSP连接数据库慢的问题
int page=1;
String sql="select * from images where partake='"+page+"'";
%>这样写你试试看.可不可以.
String sql="select * from images where partake="+p;
<%@ page import="java.sql.*"%><%
String PageRecordString=request.getParameter("PageRecord");
String PageIDString=request.getParameter("PageID");int PageRecordInt=Integer.parseInt(PageRecordString);
int PageIDInt=Integer.parseInt(PageIDString);if(PageRecordInt<=0)PageRecordInt=1;
if(PageIDInt<=0)PageIDInt=1;int ScreenOutInt=(PageIDInt-1)*PageRecordInt;String PageRecord=new Integer(PageRecordInt).toString();
String PageID=new Integer(PageIDInt).toString();
String ScreenOut=new Integer(ScreenOutInt).toString();
%><%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://127.0.0.1:3306/photo?user=root&password=123456";
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String sql = "select * from images where partake=1 limit "+ScreenOut+","+PageRecord;ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第1个字段内容为:<%=rs.getString(1)%><br>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
还是出错,错误信息为
500 Servlet Exceptionjava.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:436)
at java.lang.Integer.parseInt(Integer.java:518)
at _jsp._index__jsp._jspService(/index.jsp:8)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.pageservice(Page.java:571)
at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:155)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:190)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:177)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:331)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:464)
at com.caucho.util.ThreadPool.run(ThreadPool.java:408)
at java.lang.Thread.run(Thread.java:534)
Resin-3.0.8 (built Tue, 08 Jun 2004 02:25:40 PDT)
String p=new Integer(page).toString();
String sql="select * from images where partake='"+p+"'";
int PageIDInt=Integer.parseInt(PageIDString);其中 PageRecordString 或者 PageIDString 为 null
你可以改成 下面的代码 试试
int PageRecordInt;
try {
PageRecordInt=Integer.parseInt(PageRecordString);
} catch (NumberFormatException e) {
PageRecordInt = 0;
}
int PageIDInt=Int;
try {
PageIDInt=Integer.parseInt(PageIDString);
} catch (NumberFormatException e) {
PageIDInt = 0;
}
错误原因为程序中出现了空值,看看你自己的程序中变量的赋值可能有问题
String sql = "select * from images where partake='"+page+"'";
变为
String sql = "select * from images where partake='"+((Integer)page.toString())+"'";