简体   繁体   中英

HTTP-Get request returns HTML-Code (Google AppEngine)

I am using an AppEngine Server to answer HTTP-Get requests of my app, but the request always returns the HTML of the index.html.

This is my doGet-Method:

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String name = req.getParameter("name");
    String score = req.getParameter("score");
    if(score==null && name!=null){
        resp.getWriter().println(name);
    }
    else if(name!=null && score!=null){
        int p = Integer.parseInt(score);
        addHighscore(name, p);
    }
    else{
        resp.getWriter().println("error");
    }
}

so if i type the url http://high-1212.appspot.com/?name=test into my browser, i want it to return the value of the name parameter, but it only returns the web page. So my app does not display the value of the parameter either, but the HTML-Code. For that reason I guess, it's because of the doGet-Method. But I don't understand, what's wrong.

By default the home page will be loaded when you visit the website. If you want to display the data you are sending, you have to do in the response page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM