服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

【开发框架】tapestry4.1中注入httprequest

最近在公司的项目后台中需要加入的对用的ip的记录,用户登录后要记录用户ip等相关新防止其他用户拦截到jsessionid后,伪造jsessionid进行操作。
第一次接触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());


扫描关注微信公众号