我正在开发一个关于eclipse的GWT项目,当我运行开发模式时,一切正常。但是当我在tomcat服务器上部署WAR文件(按照本指南生成click)时,http://localhost:8080/myproj/
仅显示空白页面。
我尝试在Window.alert("..")
方法中添加onModuleLoad()
作为第一行,并且它正确显示。
清除浏览器缓存是没用的。
服务器启动没有问题也没有例外。
我该怎么做才能解决这个问题?
这是我的入门级课程
public class Segnalazioni_Degrado implements EntryPoint {
protected static List<Macrocategoria> listaMacrocategorie;
protected static List<Segnalazione> segnalazioniAttiveCached = new ArrayList<Segnalazione>();
protected static List<SegnalazioneRisolta> segnalazioniRisolteCached = new ArrayList<SegnalazioneRisolta>();
protected static final DataLayerServiceAsync dataLayerService = GWT
.create(DataLayerService.class);
protected static final LoginServiceAsync loginService = GWT
.create(LoginService.class);
protected static final MailServiceAsync mailService = GWT
.create(MailService.class);
protected static Properties props;
private final String TITOLO = "PORTALE SEGNALAZIONI DEGRADO";
private LatLng romaLatLng;
private DockLayoutPanel mainPnl;
private HorizontalPanel northPnl;
private HorizontalPanel southPnl;
private VerticalPanel westPnl;
private AbsolutePanel centerPnl;
protected static StatsPanel statsPnl;
protected static MenuPanel menuPnl;
protected static LoginPanel loginPnl;
protected static LegendPanel legendPnl;
protected static MapWidget map;
private Label titoloLbl;
private/* Button */FocusWidget areaRiservataBtn;
private Button followUsOnTwitterBtn;
private HTML mailto;
/**
* TODO tweet segnalazione inserita o risolta, porta su .css tutto il
* possibile, prendi tutto da config, fai log su server, crea mail, leggenda
* icone, elimina file foto non solo link
*/
public void onModuleLoad() {
loadProps();
buildUI();
}
void loadProps() {
props.set("scarsa manutenzione manto stradale", "images/red.png");
props.set("veicolo abbandonato", "images/red.png");
props.set("discarica abusiva", "images/green.png");
props.set("accumulo spazzatura", "images/green.png");
}
void buildUI() {
Maps.loadMapsApi("", "2", false, new Runnable() {
public void run() {
buildHomePage();
}
});
}
private void buildHomePage() {
mainPnl = new DockLayoutPanel(Unit.PCT);
mainPnl.setStyleName("mainPanel");
northPnl = new HorizontalPanel();
northPnl.setStyleName("northPanel");
southPnl = new HorizontalPanel();
southPnl.setStyleName("southPanel");
westPnl = new VerticalPanel();
westPnl.setStyleName("westPanel");
centerPnl = new AbsolutePanel();
centerPnl.setStyleName("centerPnl");
loginPnl = new LoginPanel();
statsPnl = new StatsPanel();
menuPnl = new MenuPanel();
Segnalazioni_Degrado.dataLayerService
.getListaMacrocategorie(new AsyncCallback<List<Macrocategoria>>() {
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
@Override
public void onSuccess(List<Macrocategoria> result) {
Segnalazioni_Degrado.listaMacrocategorie = result;
centerPnl.add(new LegendPanel());
}
});
/**
* costruisco la Google Map
*/
Size mapSize = Size.newInstance(500, 500);
MapOptions mapOpts = MapOptions.newInstance();
mapOpts.setSize(mapSize);
romaLatLng = LatLng.newInstance(41.8902624, 12.4923096);
map = new MapWidget(romaLatLng, 12, mapOpts);
map.checkResizeAndCenter();
map.setSize("99%", "99%");
map.addControl(new LargeMapControl());
map.setDoubleClickZoom(true);
map.setScrollWheelZoomEnabled(true);
map.setStyleName("map");
/**
* costruisco il titolo del portale
*/
titoloLbl = new Label(TITOLO);
titoloLbl.setStyleName("titolo");
/**
* costruisco bottone per accedere ad area riservata
*/
/* areaRiservataBtn = new Button("Accedi all'area riservata"); */
areaRiservataBtn = new Button("AREA RISERVATA");
areaRiservataBtn.setStyleName("bottomBtn");
areaRiservataBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
new AreaRiservataDialog();
}
});
/**
* costruisco bottone twitter
*/
followUsOnTwitterBtn = new Button();
followUsOnTwitterBtn.addStyleName("bottomBtn");
followUsOnTwitterBtn.addStyleName("twitter");
followUsOnTwitterBtn
.getElement()
.appendChild(
new HTML(
"<div><img src=images/twitter.gif><b>segui @stop_degrado</b></div>")
.getElement());
followUsOnTwitterBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.open("https://twitter.com/stop_degrado", "_blank", "");
}
});
/**
* costruisco bottone mailto
*/
mailto = new HTML("<a href=mailto:dummy@fake.foo> Contattaci </a>");
mailto.setStyleName("bottomBtn");
/**
* creo bottone ABOUT US
*/
Button aboutus = new Button("ABOUT US");
aboutus.setStyleName("bottomBtn");
aboutus.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
new AboutUsPopup();
}
});
northPnl.add(titoloLbl);
northPnl.add(loginPnl);
westPnl.add(menuPnl);
westPnl.add(statsPnl);
southPnl.add(followUsOnTwitterBtn);
southPnl.add(aboutus);
southPnl.add(areaRiservataBtn);
southPnl.add(mailto);
centerPnl.add(map);
mainPnl.addNorth(northPnl, 8);
mainPnl.addWest(westPnl, 30);
mainPnl.addSouth(southPnl, 3.5);
mainPnl.add(centerPnl);
RootLayoutPanel.get().add(mainPnl);
MenuPanel.refreshBtn.click();
}
}
答案 0 :(得分:1)
我认为这是NullPointer
:
protected static Properties props; // << NULL
public void onModuleLoad() {
loadProps(); // props is still NULL
buildUI();
}
void loadProps() {
// props is still NULL
props.set("scarsa manutenzione manto stradale", "images/red.png"); // BANG!
[...]
顺便说一下:
你为什么要props
静态?您只有一个EntryPoint实例。所以不能分享任何州。