我有一个jsp,其中我有select标签,我想从我的Servlet中的jsp中的select中获取和选择的值
<select id="listoffood" name="dropdown" onchange="foodname();">
<option value="bg">Burger</option>
<option value="pas">pasta</option>
<option value="pi">pizza</option>
</select>
<div id='content'></div>
这是javascript代码
function foodname()
{
var xmlHttpReq = false;
var self = this;
document.getElementById('content').innerHtml='';
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', "InformationServlet", true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.send(null);
self.xmlHttpReq.onreadystatechange= function ()
{
//alert(document.getElementById('content'));
if (self.xmlHttpReq.readyState==4)
{
if (self.xmlHttpReq.status == 200)
{
document.getElementById('content').innerHTML=self.xmlHttpReq.responseText;
}
}
};
}
我所做的是使用了这样的获取属性,但它无法正常工作,显示为空
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
// TODO Auto-generated method stub
String coun = request.getParameter("dropdown");
PrintWriter out=response.getWriter();
System.out.println("here : "+coun);
}
提前致谢,任何一段代码都非常感谢。