Struts2 ognl调用action有参数的方法

action:
    public String busiRangeNameById(Integer busiRange){
        if(busiRange==null)return "";
        ProductType productType = companyManageFacade.getProductType(busiRange);
        if(productType == null)return "";
        else return productType.getLargetype(); 
    }

如果这样
<s:property value="%{busiRangeNameById(companyEmployeeInfo.company.busirange)}" />

<s:property value="%{busiRangeNameById('companyEmployeeInfo.company.busirange')}" />
是不会调用该方法的,批判下,忒不智能了,freemarker就可以
如果这样:
<s:property value="%{busiRangeNameById(${companyEmployeeInfo.company.busirange})}" />
则会报错,传入的参数不能是表达式

最终写法:先放到request中,然后从request中取值
<c:set var="busirange" value="${companyEmployeeInfo.company.busirange}" scope="request"/>
<s:property value="%{busiRangeNameById(#request.busirange)}" />

你可能感兴趣的:(ognl,参数方法,web,struts2)