weixin_42446630
weixin_42446630
2011-04-30 17:43

要如何修改就能实现点击页面中某列标题跳转到相应的信息页面?

  • struts

毕设中,遇到点问题。请熟手们帮下忙,多谢了。

怎样修改就能将页面的值传入action中?(primarykey(eno,post))


index.jsp中列表代码

<s:iterator value="newinv" var="inv">
<tr>
<td>
<a href="viewinvpar.action"><s:property value="#inv.post"/>
</a>
</td>
<td>
<s:property value="#inv.pnum" />
</td>
<td>
<s:property value="#inv.ename" />
</td>
<td>
<s:property value="#inv.pdate" />
</td>
</tr>
</s:iterator>

 相关的数据库列名

<!--StartFragment -->

 

 

Action中的方法:

public class StuAction extends ActionSupport{

 /**
  *
  */
 private static final long serialVersionUID = 1L;
 private List<Enterprise> newinv=new ArrayList<Enterprise>();
 private List<Students> myapp=new ArrayList<Students>();
 private Enterprise ent=new Enterprise();
 private Students myinfo=new Students();
 LoginAction la=new LoginAction();
 StuSerImp stu_ser=new StuSerImp();
 /**
  * 查看招聘信息详情
  * @return
  */
 public String viewInvPar(){
  StuSerImp stu_ser=new StuSerImp();
  try {

   this.ent=stu_ser.viewInvPar(this.ent.getEname(),this.ent.getPost());//将从页面得到的参数值如何传到这里?这里怎么修改?页面修改为<a href="*.action?id=XX">这个XX是如何决定的?在数据库设置还是在select语句中设置?
  

  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return SUCCESS;
 }
 public String viewMyApp(){
  StuSerImp stu_ser=new StuSerImp();
  try {
   this.myapp=stu_ser.viewMyApp(la.getUserid());
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return SUCCESS;
  
 }
 public List<Enterprise> getNewinv() {
  return newinv;
 }

 public void setNewinv(List<Enterprise> newinv) {
  this.newinv = newinv;
 }
 public Students getMyinfo() {
  return myinfo;
 }
 public void setMyinfo(Students myinfo) {
  this.myinfo = myinfo;
 }
 public List<Students> getMyapp() {
  return myapp;
 }
 public void setMyapp(List<Students> myapp) {
  this.myapp = myapp;
 }

}

StuSerImp中相应方法:

public Enterprise viewInvPar(String ename, String post) throws SQLException {
  StuDaoImp dao=new StuDaoImp();
  return dao.viewInvPar(ename,post);
 }

StuDaoImp中的方法:

 public Enterprise viewInvPar(String ename, String post) throws SQLException {
  Enterprise ent =new Enterprise();
  Connection conn = DateBaseConnection.getConnection();
  Statement stmt = conn.createStatement();
  String sql="SELECT post,ename,pnum,funab,linkman,tel,email,wadr,pdate,wrpsb FROM pap p,ent e " +
    "WHERE e.eno=p.eno AND e.ename='"+ename+"' AND post='"+post+"'";
  ResultSet result = stmt.executeQuery(sql);
  while (result.next()) {
   String post1 = result.getString("post");
   String ename1 = result.getString("ename");
   int pnum = result.getInt("pnum");
   String funab=result.getString("funab");
   String linkman=result.getString("linkman");
   String tel=result.getString("tel");
   String email=result.getString("email");
   String wadr=result.getString("wadr");
   Date pdate = result.getDate("pdate");
   String wrpsb=result.getString("wrpsb");

   ent.setPost(post1);
   ent.setEname(ename1);
   ent.setPnum(pnum);
   ent.setFunab(funab);
   ent.setLinkman(linkman);
   ent.setTel(tel);
   ent.setEmail(email);
   ent.setWadr(wadr);
   ent.setPdate(pdate);
   ent.setWrpsb(wrpsb);

  }
  conn.close();
  return ent;
 }

Model中的属性:

// -------------------企业基本信息----------------//
 // 上市编号
 private String eno;
 // 企业名称
 private String ename;
 // 企业简介
 private String entsyn;
 // 企业网址
 private String enet;
 // 所在地
 private String eadr;
 // 登录密码
 private String epwd;
 // 用户类型
 private String usertype;
 // ---------------------企业招聘信息--------------------//
 // 招聘职位
 private String post;
 // 招聘人数
 private int pnum;
 // 工作责任
 private String wrpsb;
 // 职能要求
 private String funab;
 // 联系人
 private String linkman;
 // 电话
 private String tel;
 // 电子邮箱
 private String email;
 // 工作地点
 private String wadr;
 // 发布时间
 private Date pdate;

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答