我正在使用HTTP来应答我的应用程序的HTTP请求,但请求总是返回index.html的AppEngine。
这是我的doGet方法:
@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");
}
}因此,如果我在浏览器中输入url,我希望它返回http://high-1212.appspot.com/?name=test参数的值,但它只返回网页。因此,我的应用程序也不会显示参数的值,而是显示HTML-Code。出于这个原因,我猜,这是因为doGet方法。但我不明白,出什么事了。
发布于 2016-02-06 23:34:49
默认情况下,主页将在您访问网站时加载。如果您想要显示要发送的数据,则必须在响应页面中执行此操作。
https://stackoverflow.com/questions/35242240
复制相似问题