2009-11-24 90 views
0

我正在使用具有自动数据传输和类型转换的java bean。 例如:Struts 2原始类型的数据传输和类型转换

public class MyAction 
{ 
    public String execute(){ 
// .... 
    } 

private double price; 
public getPrice(){ 
    return price; 
} 

public setPrice(double price){ 
    this.price=price; 
} 
} 

让我的要求是http://localhost:8080/my.action?price=21.3 然后在setPrice我会得到的价格变量的值等于213 我的事情发生这种情况,因为罗马尼亚文化组。在这种文化中,双倍呈现为21,3而不是其他的21.3。 在.NET中,这种情况下有一些称为InvariantCulture的东西。我如何在Struts中做类似的事情,并且应该指定这个设置。

回答

1

您是否设置了struts.properties?

实施例:

struts.locale=en_US 
struts.i18n.encoding=UTF-8 

struts.properties