最近在公司的项目后台中需要加入的对用的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());
闽公网安备 35060202000074号