struts2拦截器的通配符访问 [英] struts2 Interceptor's wildcard access
本文介绍了struts2拦截器的通配符访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带通配符的动作 y 我想在拦截器中访问这个变量
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
这篇关于struts2拦截器的通配符访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文