URL:http://localhost/post.do?paramId=1¶mName=name#top
在JAVA中用正则表达式获取到 post.do
在JAVA中用正则表达式获取到 post.do
解决方案 »
- hibernate配置问题
- JSP显示调用Servlet里面的List
- 请问在xp系统中已安装了SQLServer2005,再安装Oracle.10g会有冲突吗?
- 请问如何使用jfreechart生成这个图表
- 怎样通过类名访问servlet,不用在web.xml配置
- 新手问题,JSP页面中图标无法显示
- 网络支付方式
- 关于提问的一点看法,欢迎交换意见
- ?:jsp的运行机制或运行原理是如何的,who能给我一个解释,谢谢!
- 现在公司在做网页游戏,前台用flex,后台用java,有个问题要问下大家。
- 求助向MS-SQL中插入图片,并显示出来!请高手帮帮忙,谢谢了!
- sql server2000 jdbc连接问题~大家帮忙!
Pattern s=Pattern.compile("http://localhost/(.*)\\?");
Matcher m=s.matcher(href);
if(m.find())
return m.group(1);
else
return null;
}
Pattern s=Pattern.compile("http://.*/(.*)\\?");
Matcher m=s.matcher(href);
if(m.find())
return m.group(1);
else
return null;
}
比如说
URL:http://localhost/user/post.do?paramId=1¶mName=name#top
URL:http://localhost/user/post.do我这里倒是有一个JS的正则表达式,就是不知道怎么转换成JAVA的,高人啊,帮帮忙return location.href.replace(/^.*\/([^\/\?^\/\#]*).*$/,"$1");
这个正则表达式适用于http://localhost的和http://192.168.8.8这种的。希望对你有帮助
这个应该匹配URL:http://localhost/ 后加入多个文件夹的
楼主,我刚才试了下,这个可以符合你的要求。域名变化也可以,路径多几个文件夹也可以。
Pattern s=Pattern.compile("http://.*/(.*)\\?");
我测试了 及时多个文件夹名也没问题
public static String getHref(String href){
Pattern s=Pattern.compile("http://.*/(.*)\\?");
Matcher m=s.matcher(href);
if(m.find())
return m.group(1);
else
return null;
}
你试试?肯定对的取组~以这个开使 以?结束