-2

这是我的托管 Bean 类,

公共类 MapBean 实现可序列化 {

private MapModel polylineModel;
public MapBean() {
    createMap();
}

 public void createMap(){
    try {
        polylineModel = new DefaultMapModel();
        LatLng coord;
        String query = "select a.lan,a.lat from country;";  
        Connector conn = new Connector();
        Statement str = (Statement) conn.getConn().createStatement();
        ResultSet res = str.executeQuery(query);
        Polyline polyline1;
        polyline1 = new Polyline();
        while(res.next()){
            coord= new LatLng(Integer.parseInt(res.getString(2)), Integer.parseInt(res.getString(1))); 

            polyline1.getPaths().add(coord); 
     }
        polyline1.setStrokeWeight(10);  
        polyline1.setStrokeColor("#FF9900");  
        polyline1.setStrokeOpacity(0.7);  

        polylineModel.addOverlay(polyline1);
    } catch (SQLException ex) {
        Logger.getLogger(MapBean.class.getName()).log(Level.SEVERE, null, ex);
    }




 }
  public MapModel getPolylineModel() {  
    return polylineModel;  
}  

public void onPolylineSelect(OverlaySelectEvent event) {  
    addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Polyline Selected", null));  
}  

public void addMessage(FacesMessage message) {  
    FacesContext.getCurrentInstance().addMessage(null, message);  
}  

但问题是当它被编译时它给出了一个像这样的错误“不能实例化类:org.primefaces.examples.view.MapBean”。是什么原因??

4

1 回答 1

1

如果 LatLng 支持双精度,请使用此代码。

coord= new LatLng(Double.parseDouble(res.getString(2)), Double.parseDouble(res.getString(1))); 
于 2012-11-26T05:42:30.737 回答