0
我正在使用AppEngine服務器來回答我的應用程序的HTTP-Get請求,但請求始終返回index.html的HTML。HTTP-Get請求返回HTML代碼(Google 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");
}
}
所以,如果我輸入網址http://high-1212.appspot.com/?name=test
到我的瀏覽器,我希望它返回名稱參數的值,但它只返回的網頁。所以我的應用程序不會顯示參數的值,而是顯示HTML代碼。出於這個原因,我想,這是因爲doGet-Method。但我不明白,什麼是錯的。
對這些術語進行網絡搜索:web.xml,servlet-mapping – konqi