struts2类型转化问题
以下代码有误吗?publicclassPointConverextendsStrutsTypeConverter{@OverridepublicObjectconvert...
以下代码有误吗?
public class PointConver extends StrutsTypeConverter {
@Override
public Object convertFromString(Map arg0, String[] values, Class arg2) {
List<Point> list= new ArrayList<Point>();
for (int i=0;i<values.length;i++)
{
Point point= new Point();
String[] paramValues = values[i].split(",");
int x = Integer.parseInt(paramValues[0]);
int y = Integer.parseInt(paramValues[1]);
point.setX(x);
point.setY(y);
list.add(point);
}
return list;
}
@Override
public String convertToString(Map arg0, Object o)
{
List<Point> list = (List<Point>)o;
StringBuilder sb = new StringBuilder();
sb.append("[");
int number = 0;
for (Point point : list)
{
++number;
int x = point.getX();
int y = point.getY();
sb.append(number).append("x=").append(x).append("y=").append(y);
}
sb.append("]");
return sb.toString();
}
} 展开
public class PointConver extends StrutsTypeConverter {
@Override
public Object convertFromString(Map arg0, String[] values, Class arg2) {
List<Point> list= new ArrayList<Point>();
for (int i=0;i<values.length;i++)
{
Point point= new Point();
String[] paramValues = values[i].split(",");
int x = Integer.parseInt(paramValues[0]);
int y = Integer.parseInt(paramValues[1]);
point.setX(x);
point.setY(y);
list.add(point);
}
return list;
}
@Override
public String convertToString(Map arg0, Object o)
{
List<Point> list = (List<Point>)o;
StringBuilder sb = new StringBuilder();
sb.append("[");
int number = 0;
for (Point point : list)
{
++number;
int x = point.getX();
int y = point.getY();
sb.append(number).append("x=").append(x).append("y=").append(y);
}
sb.append("]");
return sb.toString();
}
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询