Struts2.0中关于自定义映射器的扩张ActionMapper进行URL中编码设置

Struts2.0中关于自定义映射器的扩展ActionMapper进行URL中编码设置? Struts2.0 采用默认的映射器为Default

Struts2.0中关于自定义映射器的扩展ActionMapper进行URL中编码设置

? Struts2.0 采用默认的映射器为DefaultActionMapper:

public class DefaultActionMapper implements ActionMapper

??? protected static final String METHOD_PREFIX = "method:";

??? protected static final String ACTION_PREFIX = "action:";

??? protected static final String REDIRECT_PREFIX = "redirect:";

??? protected static final String REDIRECT_ACTION_PREFIX = "redirectAction:";

?

扩展如下:

public class EncodedActionMapper extends DefaultActionMapper {
??? @Override
??? public String getUriFromActionMapping(ActionMapping mapping) {
??????? try {
??????????? return URLEncoder.encode(super.getUriFromActionMapping(mapping), "UTF-8").replaceAll("%2F", "/");
??????? } catch (UnsupportedEncodingException e) {
??????????? // ignore
??????????? return null;
??????? }
??? }
}

?

在Struts2.0中配置Action映射器的采用的非默认映射类

# struts.custom.properties=application,com/webwork/extension/custom

struts.mapper.class=com.unutrip.callcenter.web.ext.EncodedActionMapper

?

也可以在struts.xml 的常量配置

?

?

?

?

?

?

?