<div class="siteSearch">
<a href="javascript:gSearch()" class="searchBtn"></a>
<input type="text" maxlength="50" id="topKeyWord" class="keyWord" value="请输入搜索关键字" onfocus="this.value='';this.style.color='#333'">
</div>
<script type="text/javascript">
if( ''!='' ){ document.getElementById('topKeyWord').value=''; }
document.getElementById("topKeyWord").onkeydown=function(e){
e = e || window.event;
if(e.keyCode==13) {gSearch();}
}
function gSearch(){
var keyword = document.getElementById('topKeyWord').value;
if(keyword=='' || keyword=="请输入搜索关键字"){ alert("请输入搜索关键字"); }
else{
//window.location = 'search.do?command=blurQuery&keyword='+encodeURI(keyword);
window.location = 'search.do?command=blurQuery&keyWord='+keyword;
}
}
</script>
然后在Action类 中用request.getParameter获取
String keyWord = request.getParameter("keyWord");
但获取不了keyWord的值?为什么?谢谢!!
------解决思路----------------------
你直接在Action类中写一句private String keyWord;
然后生成他的set和get方法,keyWord值就会在调用类的时候根据名字直接注入到类中,你就可以直接使用keyWord了