我有通配符这个动作:
@Namespace("/posts")
public class SearchPostBeansAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(SearchPostBeansAction.class);
@Override
@Actions({
@Action(value="/{search1}/{param1}/",results={
@Result(name=ACTION_SUCCESS,location="classic.main.general", type="tiles")})
})
public String execute() throws Exception {
logger.info("Action: " + getInvocatedURL() );
String forward = SUCCESS;
logger.info("getSearch1( " + getSearch1() + " )");
logger.info("getParam1( " + getParam1() + " )");
return forward;
}
}
执行结果:
- INFO (com.silver.front.view.actions.SearchPostBeansAction) - Action:
/posts/category/cars/
- INFO (com.silver.front.view.actions.SearchPostBeansAction) -
getSearch1( category )
- INFO (com.silver.front.view.actions.SearchPostBeansAction) -
getParam1( cars )
如果我拦截该动作:
@InterceptorRef("seoFilter")
@Namespace("/anuncios")
public class SearchPostBeansAction extends ActionSupport{
private static final long serialVersionUID = 1L;
...
}
执行结果:
- INFO (com.silver.front.view.actions.SearchPostBeansAction) - Action:
/posts/category/cars/
- INFO (com.silver.front.view.actions.SearchPostBeansAction) -
getSearch1( null )
- INFO (com.silver.front.view.actions.SearchPostBeansAction) -
getParam1( null)
为什么丢失通配符的参数?
这是拦截器:
public class SEOFilter implements Interceptor{
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(SEOFilter.class);
ActionSupport actionSupport = null;
public String intercept(ActionInvocation invocation) throws Exception {
actionSupport = (ActionSupport) invocation.getAction();
actionSupport.execute();
}
}