Eugeniu Torica
Eugeniu Torica

Reputation: 7574

Struts 2 data transfer and type conversions for primitive types

I'm using java beans with automatic data transfer and type conversion. Ex:

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

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

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

Let my request to be http://localhost:8080/my.action?price=21.3 Then in the setPrice I'll get price variable value equal to 213. I thing this occur because of the romanian culture set. In this cultures double are presented as 21,3 and not 21.3 as in the others. In .NET there is something called as InvariantCulture for this cases. How can I do something similar in Struts and where should be this settings specified.

Upvotes: 0

Views: 414

Answers (1)

Trick
Trick

Reputation: 3849

Do you have your struts.properties set?

Example:

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

struts.properties

Upvotes: 1

Related Questions