首页 > 解决方案 > 升级到 2.5.26 后,Struts 通配符映射不起作用

问题描述

我有一个使用通配符映射的操作类。它在 struts 2.5.22 中工作,但我尝试升级到 2.5.26(和 2.5.25),现在永远不会调用 setType。

@Component
@Namespace("/applications/proxy")
@Flow(purgeAllBefore = "Y")
@Action(value = "{type}")
@Results({@Result(name = "input", type = "dispatcher", location = "/jsp/applications/proxy.jsp"),
          @Result(name = "success", type = "redirectAction", location = "${type}", params = {"namespace", "/applications"}),
          @Result(name = "auto-select", type = "redirectAction", location = "${autoSelectUrl}", params = {"namespace", "/"})})
public class ProxyAction extends SearchSupport {
  // Struts wildcard action mapping variable for the attachment, for example: 'J', 'R', 'I', 'N', 'H'
  private String type;
 
  public String getType() {
    return type;
  }
 
  public void setType(String type) {
    this.type = type;
  }
...

标签: javastruts2

解决方案


好的,我发现了问题。strutsconfig 文件中需要此行,但文档中不需要:

<constant name="struts.matcher.appendNamedParameters" value="true"/>

推荐阅读