第一次接触Tapestry基本上没啥概念在网络搜索了相关资料看了IRequestCycle的文档通过IRequestCycle.getInfrastructure() .getRequest()获得的是经过封装的WebRequest无法满足需求在网上找到的信息是表示需要注入HttpRequest,一头雾水没概念。看到别人注入使用的是WebRequest /**注入Request*/
@InjectObject("infrastructure:request") public abstract WebRequest getRequest();
在问了同事后也使用J5的Annoation代码如下 @InjectObject("service:tapestry.globals.HttpServletRequest") public abstract HttpServletRequest getServletRequest();
在具体方法中就可以设置ip this.getVisit().setIpHostKey( new StringBuilder().append( getServletRequest().getRemoteAddr()) .append("&").append( getServletRequest().getRemoteHost()) .toString());
|