struts2拦截器的通配符访问
问题描述:
我有一个带通配符的动作,我想在拦截器中访问此变量
I have a action with a wildcard y I want to access to this variable in the interceptor
动作
@Action(value="{uri}/page",
results={
@Result(name=SUCCESS,location="/success.jsp"),
}
)
public String execute(){
...
拦截器
public String intercept(ActionInvocation actionInvocation) throws Exception {
// =( uri is not in the map
Map<String, Object> params =
actionInvocation.getInvocationContext().getContextMap();
...
我找不到在拦截器中可以找到通配符的地方
I don't find where I can get the wildcard in the interceptor
我只是找到方法:
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionConfig config = actionInvocation.getProxy().getConfig();
log.info(config.getParams().get("uri"));
答
我只是找到方法:
public String intercept(ActionInvocation actionInvocation) throws Exception {
ActionConfig config = actionInvocation.getProxy().getConfig();
log.info(config.getParams().get("uri"));
我可以做类似的事情
localhost/site/campus1/page.action
localhost/site/campus1/page.action
localhost/site/campus2/page.action
localhost/site/campus2/page.action
然后拦截器决定校园"是否存在
And the interceptor decide if the "campus" exist