当前位置: 技术问答>java相关
最原始,最简单的jsp问题!
来源: 互联网 发布时间:2017-04-26
本文导语: jdk1.4+tomcat4.1+Sql Server 2k 表中有个字段memo(备注型):用来保存输入的内容 我输入的一段文字,有好几段,现在要显示它,显示出来就是一段,没有分段,请那位高手解决一下,谢谢! String memo=rs.getString(3).replaceAll("...
jdk1.4+tomcat4.1+Sql Server 2k
表中有个字段memo(备注型):用来保存输入的内容
我输入的一段文字,有好几段,现在要显示它,显示出来就是一段,没有分段,请那位高手解决一下,谢谢!
String memo=rs.getString(3).replaceAll("
","vbcrlf");
出现下面错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 2.
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
root cause
表中有个字段memo(备注型):用来保存输入的内容
我输入的一段文字,有好几段,现在要显示它,显示出来就是一段,没有分段,请那位高手解决一下,谢谢!
String memo=rs.getString(3).replaceAll("
","vbcrlf");
出现下面错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 2.
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
root cause
|
String方法没有replaceAll(String,String)方法,我自己写了一个,你看看:
/*
×Ö·û´®Ìæ»»
*/
public static String stringreplace(String line,String oldString,String newString){
if(line==null||oldString==null||newString==null){
return "";
}
int i=0;
int j=0;
if((i=line.indexOf(oldString,i))>=0){
char[] line2=line.toCharArray();
char[] newString2=newString.toCharArray();
StringBuffer buf=new StringBuffer(line2.length);
int olength=oldString.length();
buf.append(line2,0,i).append(newString2);
i+=olength;
j=i;
while((i=line.indexOf(oldString,i))>0){
buf.append(line2, j, i-j).append(newString2);
i +=olength;
j = i;
}
buf.append(line2, j, line2.length - j);
return buf.toString();
}
return line;
}
==========================
使用方法:
source=stringreplace(source,"rn","
") ;
source=stringreplace(source,"n","
") ;
/*
×Ö·û´®Ìæ»»
*/
public static String stringreplace(String line,String oldString,String newString){
if(line==null||oldString==null||newString==null){
return "";
}
int i=0;
int j=0;
if((i=line.indexOf(oldString,i))>=0){
char[] line2=line.toCharArray();
char[] newString2=newString.toCharArray();
StringBuffer buf=new StringBuffer(line2.length);
int olength=oldString.length();
buf.append(line2,0,i).append(newString2);
i+=olength;
j=i;
while((i=line.indexOf(oldString,i))>0){
buf.append(line2, j, i-j).append(newString2);
i +=olength;
j = i;
}
buf.append(line2, j, line2.length - j);
return buf.toString();
}
return line;
}
==========================
使用方法:
source=stringreplace(source,"rn","
") ;
source=stringreplace(source,"n","
") ;