Ajax jsp页面如何获取servlet里的值。(如下描述,我想从jsp页面获取doGet()方法里A的值)
比如说我的jsp页面是这样写的。<script>varrequest=newXMLHttpRequest();request.open("GET","AjaxDemo?u...
比如说我的jsp页面是这样写的。
<script>
var request = new XMLHttpRequest();
request.open("GET", "AjaxDemo?userName="456",true);
request.send(null);
</script>
servlet页面的doGet()方法是这样写的。
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
boolean A = false;
String userName = request.getParameter("userName");
if(userName.equals("123")) A=true;
else A=false;
} 展开
<script>
var request = new XMLHttpRequest();
request.open("GET", "AjaxDemo?userName="456",true);
request.send(null);
</script>
servlet页面的doGet()方法是这样写的。
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
boolean A = false;
String userName = request.getParameter("userName");
if(userName.equals("123")) A=true;
else A=false;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询