我该怎么用:
等等
URI表示具有1个名称的Person资源,但我需要在逻辑上将第一个与最后一个分开以识别每个.我有点像最后一个例子,因为我能做到:
我尽可能返回空集合与null.我使用java.util.Collections在两种方法之间切换:
return Collections.EMPTY_LIST;
return Collections.emptyList();
Run Code Online (Sandbox Code Playgroud)
哪里emptyList()应该是类型安全的.但我最近发现:
return Collections.<ComplexObject> emptyList();
return Collections.<ComplexObject> singletonList(new ComplexObject());
Run Code Online (Sandbox Code Playgroud)
等等
我在Eclipse Package Explorer中看到了这个方法:
<clinit> () : void
Run Code Online (Sandbox Code Playgroud)
但我不知道在源代码(1.5)中是如何完成的.怎么这个神奇的tomfoolerie发生了!
编辑:如何完成静态通用类型?
我使用SecurityContextHolder和定制UserDetailsService,以获得UserDetails来自SecurityContextHolder:
Object o = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserDetailsDTO user = (UserDetailsDTO) o;
Run Code Online (Sandbox Code Playgroud)
我遗漏了空检查等,但这就是主意.我在一个@Around切入点中使用它@Aspect:
@Around("execution(* user.service.*.*(..))")
public Object audit(ProceedingJoinPoint call) throws Throwable {
// get user id
// add audit row in db
}
Run Code Online (Sandbox Code Playgroud)
看一下这个SecurityContextHolder类,它ThreadLocal默认使用一个,但切入点的东西似乎也有某种封装的线程逻辑.
是否可能存在用户冲突(即,在一个会话中为另一个并发会话中的UserB审核事件访问UserA),或者可能是空用户.
有没有更好的方法来获取凭据/用户配置文件?
我正在尝试从表单填充Bean列表:
public class Foo {
public String attr1;
public String attr2;
}
public class Bar {
public List<Foo> foos;
}
public class StrutsAction extends Action {
public Bar bar;
}
Run Code Online (Sandbox Code Playgroud)
那么在我的Struts2表单中,填充Foo的最佳方法是什么?直觉上,我想做:
<input type="hidden" name="bar.foos.attr1" />
Run Code Online (Sandbox Code Playgroud)
但这不起作用,会导致碰撞.我确定答案很简单,我忽略了它.
java ×3
collections ×1
query-string ×1
rest ×1
spring ×1
spring-mvc ×1
struts ×1
struts2 ×1
uri ×1
url ×1