100分 求一个Struts的 查询例子 (简单点的)
100分 求一个Struts的 查询例子 (简单点的)
------解决方案--------------------告诉我你的email,我发个给你罗
------解决方案--------------------chenhf128@gmail.com 我要,谢谢.
------解决方案--------------------struts-config.xml
..............
<action path= "/searchdate "
type= "com.xxx.SearchAction "
name= "SearchForm "
scope= "request ">
<forward name= "success "
path= "/list.jsp "/>
</action>
package com.xxx;
public class SearchAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res
){
ListBean lb =new ListBean();
/*读取form,以参数传给处理方法 返回结果集*/
ArrayList slist= lb.getList((SearchForm)form);
/*将结果集存放到request中*/
req.setAttribute( "myList ",slist);
ActionForward forward= new ActionForward();
forward=mapping.findForward( "success ");
return forward;
}
}
SearchForm.java
...........
public class SearchForm extends ActionForm {
private String type;
private String date;
public String getType(){
return type;
}
public void setType(String args){
this.type=args
}
public String getDate(){
return date;
}
public void setDate(String args){
this.date=args
}
}
list.jsp
<html:form action= "/searchdate.do ">
<html:text property= "type "/>
<html:text property= "date "/>
</html:form>
<!--遍历结果-->
<logic:iterate id= "test " name= "myList " scope= "request ">
<bean:write name= "test " property= "xb "/>
<bean:write name= "test " property= "age "/>
</logic:iterate>
Test.java
public class Test{
private String xb;
private String age;
public String getXb(){
return xb;
}
public void setXb(String args){
this.xb=args
}
public String getAge(){
return Age;
}
public void setAge(String args){
this.age=args
}
}
你自己改一下,其中具体的查询方法自己ListBean写就可以了
------解决方案--------------------ding
------解决方案--------------------帮顶一下,顺便学习一下!
------解决方案--------------------TO zhaochunhui(没有烟抽的日子@事不过三,过三重构) :你给他写的STRUTS-CONFIG.XML文件中没写SearchForm的配置.....
------解决方案--------------------ding .end
------解决方案--------------------mark