2009-11-24 107 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