字符串截取
1、
package com.aomeisoft.jc.space.web.filter;
import java.util.HashMap;
import java.util.Map;
public class SplitTest {
public static Map<String, Long> map = new HashMap<String, Long>();
static {
map.put("lunzi", new Long(21));
}
public static void main(String[] args) {
String str = "http://lunzi.blog.24365pt.com/";
int len = str.indexOf(".blog.");
System.out.println("len="+len);
if (len == -1) {
// 转向一个特定的页面
System.out.print("转向一个特定的页面转向首页");
} else {
String targetUrl = str.substring(7, len);
if (map.get(targetUrl) != null) {
System.out.print(map.get(targetUrl));
} else {
System.out.print("该用户不存在");
}
}
}
}
2、
String blogDomain = request.getServerName();
int idx = blogDomain.indexOf(".");
if(idx<0){
}else{
blogDomain=blogDomain.substring(0,idx);
}
lunzi
2007-06-27 09:04:49
评论:2
阅读:252
引用:0
@2007-06-28 18:22:53 lunzi
谢谢hofman提示,偶试一下
urlrewrite
@2007-06-27 16:33:06 hofman
这种工作,让urlrewrite做,可能更有效率。
