【发布时间】:2016-11-28 10:12:43
【问题描述】:
我是春季和球衣的新人。我正在尝试构建一个过滤器来检查请求是否具有正确的参数。这是我要检查的 json 部分:
"request":{
"application":"1 Android Mobile",
"version":1
}
数据的元素是我的 VersionDTO 的一部分:
public class VersionDTO {
int version;
String application;
public String getApplication() {
return application;
}
public void setApplication(String application) {
this.application = application;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
}
这是我的过滤器的代码:
@Override
public void filter(ContainerRequestContext requestContext) throws FilterException {
if (isSecureURL(requestContext.getUriInfo().getPath())){}{
try {
versionFilterService.setVersionDTO(//here is where I want to pass the VersionDTO object with the data of the requestContext);
} catch (ServiceException e) {
e.printStackTrace();
}
}
}
private boolean isSecureURL(String url) {
return !UnSecureUrlEnum.isUnSecureUrl(url);
}
}
我想做的是从 ContainerRequestContext 获取数据并构建一个 VersionDTO 以将对象传递给我的服务。这可能吗??
先谢谢了!
【问题讨论】:
标签: spring-boot filter jersey