Parameters Struts:“;别名;参数名称,来自;“富吧”;至;b";

Parameters Struts:“;别名;参数名称,来自;“富吧”;至;b";,parameters,struts,names,Parameters,Struts,Names,我有一个以DTO为成员的Struts操作: public class MyAction { private MyDTO dto; void execute() { String bar = dto.getBar() ; //struts has mapped GET parameter dto.bar by calling dto.setBar() // do something with bar: return bar != null

我有一个以DTO为成员的Struts操作:

public class MyAction {
   private MyDTO dto;

   void execute() {
      String bar = dto.getBar() ;  
     //struts has mapped GET parameter dto.bar by calling dto.setBar()
     // do something with bar:
     return bar != null ? SUCCESS : INPUT;
    }
}
我希望将名为“b”的参数映射到dto.bar,只是为了使我的GET url更干净。而不是: 我想:

我知道我可以通过在我的操作中添加一个setB(最终字符串b)来实现这一点,但这会使我的代码更脆弱,更难理解


有没有一种方法可以告诉Struts进行这种映射,以便对的url调用MyAction.getDto.setBar()?

您可以使用别名拦截来实现这一点。退房: