警告:/% 3Cis = request.getContextPath()%%3E/trailpath/trailpath.nocache.js:java.lang.NumberFormatException:= r

时间:2013-07-18 11:52:06

标签: java gwt tomcat servlets jetty

我正在给代码。 的客户端

 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>

当我做Run As-Web Application时 它显示如下错误:

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项目(突然显示上面的错误).i现在没有改变任何东西。但是犯了错误。当它正在工作时,我得到了错误,这是在后期。但我必须在我的代码中使用GWT.getHostPageBaseURL()或GWT.getHostPageBaseURL()方法。我没有任何重定向到其他页面听到。我找不到任何解决办法。

POST:how to deploy GWT app to tomcat

1 个答案:

答案 0 :(得分:0)

乍一看,我说您使用JSP语法从Trail.html页面引用trailing.nocache.js文件,但服务器不将Trail.html评估为JSP(默认情况下,只有* .jsp文件被视为JSP)。

NumberFormatException: =r在评估网址(%3C%=request)时来自服务器,其中%=r(来自%=request)评估为网址转义。因此,NumberFormatException来自于尝试将=r解析为十六进制数。

解决方案:从您的Trail.html页面中删除JSP语法,或将该页面更改为JSP(例如将其重命名为Trail.jsp