我需要使用java脚本转义正则表达式特殊字符.如何实现这一点?任何帮助都应该被理解.
感谢您的快速回复.但我需要逃避正则表达式的所有特殊字符.我已经尝试了这段代码,但我无法达到结果.
RegExp.escape=function(str)
{
if (!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'gim'
);
}
return str.replace(arguments.callee.sRE, '\\$1');
}
function regExpFind() {
<%--var regex = new RegExp("\\[munees\\]","gim");--%>
var regex= new RegExp(RegExp.escape("[Munees]waran"));
<%--var regex=RegExp.escape`enter code here`("[Munees]waran");--%>
alert("Reg : "+regex);
}
Run Code Online (Sandbox Code Playgroud)
这段代码我错了什么?请指导我.
我需要使用JSF <h:graphicimage>标记或HTML <img>标记在Web应用程序中显示驻留在deploy文件夹之外的图像.我怎样才能做到这一点?
我有一个包含阿拉伯字符的xml文件.当我尝试解析文件时,会出现Exception,MalformedByteSequenceException:2字节UTF-8序列的无效字节2.我使用POI DOM来解析文档.
日志是,
2012-03-19 11:30:00,433 [ERROR] (com.infomindz.remitglobe.bll.remittance.BlackListBean) - Error
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.infomindz.remitglobe.bll.remittance.BlackListBean.updateGeneralBlackListDetail(Unknown Source)
at com.infomindz.remitglobe.bll.remittance.schedulers.BlackListUpdateScheduler.executeInternal(Unknown Source)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Run Code Online (Sandbox Code Playgroud)
例外情况只出现在Windows机器上,而不是出现在Linux机器上.如何解决这个问题.任何建议都应该引人注意.
我想显示错误消息,如"以下标题无效
1.Name
2.Roll no
Run Code Online (Sandbox Code Playgroud)
如何在jsf中使用faces消息显示这个?请帮帮我.
我前一天读过apache tomcat文档,我很困惑emptySessionPath.据我所知,如果设置为true,emptySessionPath则存储在Web应用程序的根文件夹中.请给出正确的术语定义, emptySessionPath如果设置为真和假,会发生什么?
请指导我.谢谢.
过期会话和无效会话之间有什么区别?
而且,如何使会话在java中过期?
请帮我.提前致谢.
我已经编写了使用 itext 创建报告的代码。为此,我必须添加类似于
BSJ Economy Report Date:31/12/10
Run Code Online (Sandbox Code Playgroud)
为此,我需要将制表符 (\t) 放在上述字符串之间。但我在 itext 中找不到制表符。我使用了“\t”和“\t”。这不起作用。请帮我解决这个问题。
我是JPA的新手.我正在尝试使用JPA运行一些示例代码,但是我得到以下异常:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyJPAApplicationPU
Run Code Online (Sandbox Code Playgroud)
我把我的异常信息放在这里,
INFO: Could not find any META-INF/persistence.xml file in the classpath
javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyJPAApplicationPU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at com.myJpa.TestJPA.setUp(TestJPA.java:30)
at com.myJpa.TestJPA.main(TestJPA.java:72)
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激.
我在运行JSF程序时遇到以下异常.
org.apache.jasper.JasperException: An exception occurred processing JSP page /pages/general/internalServerErrorPage.jsp at line 44
41: <link rel="shortcut icon" href="<%=request.getContextPath()%>/resources/images/infomindzicon.ico" type="image/x-icon" />
42: </head>
43: <body id="sscmsMainBody">
44: <h:form id="internalServerErrorPageForm" binding="#{ServerErrorBean.initForm}">
45: <rich:page id="richPage" theme="#{LayoutSkinBean.layoutTheme}"
46: width="#{LayoutSkinBean.layoutScreenWidth}"
47: sidebarWidth="0">
Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Parent was not null, but this component not related
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
at org.apache.jsp.pages.general.internalServerErrorPage_jsp._jspService(internalServerErrorPage_jsp.java:207)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
Run Code Online (Sandbox Code Playgroud)
这个例外的含义是什么?如何解决这个问题?
更新:我的代码如下,
public HtmlForm getInitForm() {
validateSession();
return initForm;
}
Run Code Online (Sandbox Code Playgroud)
验证会话方法是
private void validateSession() {
HttpSession session …Run Code Online (Sandbox Code Playgroud) 我需要清除数组列表,哪一种方法更好?为什么?
方法1:
List list = new ArrayList();
list.add("ram");
if(list!=null)
{
list.clear();
}
Run Code Online (Sandbox Code Playgroud)
方法2:
List list = new ArrayList();
list.add("ram");
if(list!=null && !list.isEmpty())
{
list.clear();
}
Run Code Online (Sandbox Code Playgroud)
在方法1中,我不检查列表是否为空,直接我已经清除了列表.
但是在方法2中,如果列表不是空的,我已经通过检查清除了列表
if(list!=null && !list.isEmpty())
Run Code Online (Sandbox Code Playgroud)
哪一种方法更好?方法1还是方法2?
java ×8
jsf ×3
richfaces ×2
apache-poi ×1
connector ×1
graphicimage ×1
image ×1
itext ×1
itextsharp ×1
javascript ×1
jpa ×1
jsf-2 ×1
jsp ×1
orm ×1
persistence ×1
regex ×1
session ×1
tomcat ×1
tomcat6 ×1
webserver ×1
xml ×1