急求正则表达式:不以某些字符开头,需要以某些字符结束不知道tomcat的web.xml中对于JavaServer Faces Servlet的url-pattern,正则表达式是否会起作用?我要求url-pattern表达出这样的意思:
1. 不能够以 "/FCKEditor" 开头
2. 但又必须以 ".html" 结尾
1. 不能够以 "/FCKEditor" 开头
2. 但又必须以 ".html" 结尾
调试欢乐多
你试一下,我刚学的,不确定
web.xml中定义url-pattern的时候,原以为可以使用正则表达式,老是报错.在servlet 2.4 specification中找到 SRV.11.2 Specification of MappingsIn theWeb application deployment descriptor, the following syntax is used to define
mappings:
• A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used
for path mapping.
• A string beginning with a ‘*.’ prefix is used as an extension mapping.
• A string containing only the ’/’ character indicates the “default” servlet of
the application. In this case the servlet path is the request URI minus the context
path and the path info is null.
• All other strings are used for exact matches only.这规则真是够死的,郁闷.
但我还是想知道那样写的正则表达式对不对,有人回答出来就结帖。
<input type="button" onClick="test(document.getElementById('txt').value);" value="验证">
<script>
function test(value){
var reg=/^(?!\/FCKEditor).+\.html$/g;
if(reg.test(value)){
alert("验证通过!");
}else{
alert("输入内容不能以/FCKEditor开始,必须以.html结束!");
}
}
</script>