--
您收到此信息是由于您订阅了 Google 论坛“Google App Engine 中文开发组”论
坛。
要在此论坛发帖,请发电子邮件到 google-app-e...@googlegroups.com
要退订此论坛,请发邮件至
google-app-engine-...@googlegroups.com
更多选项,请通过
https://groups.google.com/group/google-app-engine-cn-dev?hl=zh-CN?hl=zh-CN
访问该论坛
--
您收到此信息是由于您订阅了 Google 论坛“Google App Engine 中文开发组”论
坛。
要在此论坛发帖,请发电子邮件到 google-app-e...@googlegroups.com
要退订此论坛,请发邮件至
google-app-engine-...@googlegroups.com
更多选项,请通过
https://groups.google.com/group/google-app-engine-cn-dev?hl=zh-CN?hl=zh-CN
访问该论坛
>> What I said is licenced under CC-by-nd :) Email: java...@baturu.com Blog: http://blog.baturu.com
--
您收到此信息是由于您订阅了 Google 论坛“Google App Engine 中文开发组”论
坛。
要在此论坛发帖,请发电子邮件到 google-app-e...@googlegroups.com
要退订此论坛,请发邮件至
google-app-engine-...@googlegroups.com
更多选项,请通过
https://groups.google.com/group/google-app-engine-cn-dev?hl=zh-CN?hl=zh-CN
访问该论坛
呵呵, GFW的目标不是做恶吗?
https://groups.google.com
https访问已经被
杯具阿
有想探讨Java Web方面的同行吗? 看了一下 google group,发现没有几个这方面的group,所以我创建了一个,希望找一些同行们,能够一起高质量探讨技术问题。感兴趣的请加,不感兴趣的就抱歉打扰了
https://groups.google.com/group/web-based-java-in-china
jinzhou shi 写道:
杯 具阿!
图标里面竟然有河蟹 阿哈哈 杯具
--
Thanks
>> What I said is licenced under CC-by-nd :) Email: java...@baturu.com Blog: http://blog.baturu.com
filter 类如下:
/**
* Core Filter for integrating SiteMesh into a Java web application.
*
* @author Joe Walnes
* @author Scott Farquhar
* @since SiteMesh 3
*/
public class SiteMeshFilter implements Filter {
private FilterConfig filterConfig;
private static final String ALREADY_APPLIED_KEY =
"com.opensymphony.sitemesh.APPLIED_ONCE";
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
public void destroy() {
filterConfig = null;
}
/**
* Main method of the Filter.
* <p>Checks if the Filter has been applied this request. If not,
parses the page
* and applies {@link com.opensymphony.module.sitemesh.Decorator}
(if found).
*/
public void doFilter(ServletRequest rq, ServletResponse rs,
FilterChain chain)
throws IOException, ServletException {
System.err.println("===================");
HttpServletRequest request = (HttpServletRequest) rq;
HttpServletResponse response = (HttpServletResponse) rs;
ServletContext servletContext = filterConfig.getServletContext();
SiteMeshWebAppContext webAppContext = new
SiteMeshWebAppContext(request, response, servletContext);
ContentProcessor contentProcessor =
initContentProcessor(webAppContext);
DecoratorSelector decoratorSelector =
initDecoratorSelector(webAppContext);
if (filterAlreadyAppliedForRequest(request)) {
// Prior to Servlet 2.4 spec, it was unspecified whether the
filter should be called again upon an include().
chain.doFilter(request, response);
return;
}
if (!contentProcessor.handles(webAppContext)) {
// Optimization: If the content doesn't need to be
processed, bypass SiteMesh.
chain.doFilter(request, response);
return;
}
try {
Content content = obtainContent(contentProcessor,
webAppContext, request, response, chain);
if (content == null) {
return;
}
Decorator decorator =
decoratorSelector.selectDecorator(content, webAppContext);
decorator.render(content, webAppContext);
} catch (IllegalStateException e) {
// Some containers (such as WebLogic) throw an
IllegalStateException when an error page is served.
// It may be ok to ignore this. However, for safety it is
propegated if possible.
} catch (RuntimeException e) {
throw e;
} catch (ServletException e) {
request.setAttribute(ALREADY_APPLIED_KEY, null);
throw e;
}
}
protected ContentProcessor
initContentProcessor(SiteMeshWebAppContext webAppContext) {
// TODO: Remove heavy coupling on horrible SM2 Factory
Factory factory = Factory.getInstance(new Config(filterConfig));
factory.refresh();
return new PageParser2ContentProcessor(factory);
}
protected DecoratorSelector
initDecoratorSelector(SiteMeshWebAppContext webAppContext) {
// TODO: Remove heavy coupling on horrible SM2 Factory
Factory factory = Factory.getInstance(new Config(filterConfig));
factory.refresh();
return new
DecoratorMapper2DecoratorSelector(factory.getDecoratorMapper());
}
/**
* Continue in filter-chain, writing all content to buffer and parsing
* into returned {@link com.opensymphony.module.sitemesh.Page}
object. If
* {@link com.opensymphony.module.sitemesh.Page} is not parseable,
null is returned.
*/
private Content obtainContent(ContentProcessor contentProcessor,
SiteMeshWebAppContext webAppContext,
HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
ContentBufferingResponse contentBufferingResponse = new
ContentBufferingResponse(response, contentProcessor, webAppContext);
chain.doFilter(request, contentBufferingResponse);
// TODO: check if another servlet or filter put a page object in
the request
// Content result = request.getAttribute(PAGE);
// if (result == null) {
// // parse the page
// result = pageResponse.getPage();
// }
webAppContext.setUsingStream(contentBufferingResponse.isUsingStream());
return contentBufferingResponse.getContent();
}
private boolean filterAlreadyAppliedForRequest(HttpServletRequest
request) {
if (request.getAttribute(ALREADY_APPLIED_KEY) == Boolean.TRUE) {
return true;
} else {
request.setAttribute(ALREADY_APPLIED_KEY, Boolean.TRUE);
return false;
}
}
public void setFilterConfig(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
public FilterConfig getFilterConfig() {
return filterConfig;
}
}
public void doFilter(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws IOException, ServletException {
杨浩 写道:
> 支持拦截的阿!
> 看看后台日志,你请求拦截的地址看看输出什么了?
> --
> 您收到此信息是由于您订阅了 Google 论坛“Google App Engine 中文开发组”论
> 坛。
> 要在此论坛发帖,请发电子邮件到 google-app-e...@googlegroups.com
> 要退订此论坛,请发邮件至
> google-app-engine-...@googlegroups.com
> 更多选项,请通过
> https://groups.google.com/group/google-app-engine-cn-dev?hl=zh-CN?hl=zh-CN
> 访问该论坛
妈的,难道这是 google api 故意这么设计的? 之前没发现有这样的问题
杨浩 写道:
杨浩 写道:
> 刚才自己写了一个,却是无法拦截/下面的