jsp里如何替换字符串的一个字符 ( 积分: 50 )

  • 主题发起人 主题发起人 寻找
  • 开始时间 开始时间

寻找

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把字符串里的´替换为´´,如何?
用字符串对象方法replaceAll,在jcreate里编译没有错误,但在Jsp页面里有错误
如何解决?
 
我想把字符串里的´替换为´´,如何?
用字符串对象方法replaceAll,在jcreate里编译没有错误,但在Jsp页面里有错误
如何解决?
 
什么错误,是不是你没有转意?
能看看你的代码吗?
 
To:yangxiao_jiang
代码很简单
<%@ page contentType="text/html;
charset="
language="java"
import="java.sql.*"
errorPage=""
%>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
<title>无标题文档</title>
<%
String str="a";
String a;
a=str.replaceAll("'","''");
%>
</head>
<body>
</body>
</html>
jsp出错:
Unhandled error! You might want to consider having an error page to report such errors more gracefully
com.sun.jsp.JspException: Compilation failed
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at javax.servlet.ServletException.(Compiled Code)
at com.sun.jsp.JspException.(JspException.java:29)
at com.sun.jsp.compiler.Main.compile(Compiled Code)
at com.sun.jsp.runtime.JspLoader.compile(JspLoader.java:86)
at com.sun.jsp.runtime.JspLoader.loadJSP(Compiled Code)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.loadIfNecessary(Compiled Code)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(Compiled Code)
at com.sun.jsp.runtime.JspServlet.serviceJspFile(Compiled Code)
at com.sun.jsp.runtime.JspServlet.service(Compiled Code)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(Compiled Code)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(Compiled Code)
at com.ibm.servlet.engine.webapp.IdleServletState.service(Compiled Code)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(Compiled Code)
at com.ibm.servlet.engine.webapp.ServletInstance.service(Compiled Code)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(Compiled Code)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(Compiled Code)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(Compiled Code)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(Compiled Code)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(Compiled Code)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(Compiled Code)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(Compiled Code)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(Compiled Code)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(Compiled Code)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(Compiled Code)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(Compiled Code)
at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(Compiled Code)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(Compiled Code)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(Compiled Code)
at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(Compiled Code)
at java.lang.Thread.run(Compiled Code)

 
charset=这里要设置编码
charset=gb2312
这样就好了。
 
上面的已经设置了!
 
<%@ page contentType="text/html;
charset="
language="java"
import="java.sql.*"
errorPage=""
%>
这里的charset=没有设置
头不对,当然编译不了了。
 
<%@ page contentType="text/html;
charset=GBK"
language="java"
import="java.sql.*"
errorPage=""
%>
 
多人接受答案了。
 

Similar threads

回复
0
查看
848
不得闲
I
回复
0
查看
606
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部