我给代码。 客户
package a.b.client;
public class Trail implements EntryPoint{
Button b=new Button("Click");
FlowPanel fs=new FlowPanel();
int i=0;
private final TrailInterfaceAsync obj = GWT
.create(TrailInterface.class);
@Override
public void onModuleLoad() {
RootPanel.get().add(b);
RootPanel.get().add(fs);
b.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
obj.getDetails(new AsyncCallback<ArrayList<String>>(){
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ArrayList<String> result) {
try{
System.out.println("size:"+result.size());
for(i=1;i<=result.size()-1;i++)
{
HTML l=new HTML(result.get(i).toString());
fs.add(l);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}});
}});
}
}
服务器
package a.b.server;
import a.b.client.TrailInterface;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class TrailImpl extends RemoteServiceServlet implements TrailInterface {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public ArrayList<String> getDetails() {
Connection con;
Statement stmt;
ResultSet resultSet;
ArrayList<String> details=new ArrayList<String>();
try
{
System.setSecurityManager(null);
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager
.getConnection("jdbc:mysql://69.162.121.114:3306/AyushCareDB?"
+ "user=xxxxx&password=yyyyyy");
if(con!=null)
System.out.println("success!");
else
System.out.println("fail!");
stmt = con.createStatement();
// Result set get the result of the SQL query
resultSet = stmt.executeQuery("select * from LocationTable");
while(resultSet.next())
{
details.add(resultSet.getString(1));
}
}
catch(Exception e)
{
e.printStackTrace();
}
return details;
}
}
web.xml
<!-- Servlets -->
<servlet>
<servlet-name>TrailImpl</servlet-name>
<servlet-class>a.b.server.TrailImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TrailImpl</servlet-name>
<url-pattern>/trailpath/trail</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Trail.html</welcome-file>
当我运行 Web 应用程序时,它显示如下错误:
Jul 18, 2013 5:02:09 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /%3C%=request.getContextPath()%%3E/trailpath/trailpath.nocache.js: java.lang.NumberFormatException: =r
我不明白它是从哪里来的?请帮我。
以及我之前尝试在Tomcat中部署这个简单的GWT项目(突然它显示上述错误)。我现在没有改变任何东西。但得到上述错误。虽然它正在工作,但我收到了发布错误。但是我必须在我的代码中使用 GWT.getHostPageBaseURL() 或 GWT.getHostPageBaseURL() 方法。我没有任何重定向到其他页面听到。我找不到任何解决方案。