在struts中获取form中的select的值时action类该怎么写,求详细点。
jsp中:<formaction="../eszzAction_findEszzAllByType.action"method="post"><selectname="t...
jsp中:<form action="../eszzAction_findEszzAllByType.action" method="post" >
<select name="type" id="search">
<option value="生活用品">
生活用品
</option>
<option value="图书资料">
图书资料
</option>
<option value="学习用品">
学习用品
</option>
<option value="体育用品">
体育用品
</option>
</select>
<input name="submit" type="submit" value="查询" >
</form>
action类:public String findEszzAllByType(){
String type = (String) request.getParameter ("type");
if (type =="图书资料"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '图书资料'" );
ActionContext.getContext().put("eszzList", eszzList);
}else if (type =="生活用品"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '生活用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}else if (type =="体育用品"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '体育用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}else {
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type ='学习用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}
</td> 展开
<select name="type" id="search">
<option value="生活用品">
生活用品
</option>
<option value="图书资料">
图书资料
</option>
<option value="学习用品">
学习用品
</option>
<option value="体育用品">
体育用品
</option>
</select>
<input name="submit" type="submit" value="查询" >
</form>
action类:public String findEszzAllByType(){
String type = (String) request.getParameter ("type");
if (type =="图书资料"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '图书资料'" );
ActionContext.getContext().put("eszzList", eszzList);
}else if (type =="生活用品"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '生活用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}else if (type =="体育用品"){
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type = '体育用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}else {
List<Eszz> eszzList = objectManager.getUtil("from Eszz where type ='学习用品'" );
ActionContext.getContext().put("eszzList", eszzList);
}
</td> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询