- SQL code
--表一create table bug_project( id number, name varchar(100) not null, constraint PK_project primary key(id));表二create table bug_detail( id number, projectId number not null, severity number not null, tiele varchar(100) not null, reportuser varchar(50) not null, createdate date not null, constraint PK_detail primary key(id), constraint FK_project foreign key(projectId) references bug_project(id));
- Java code
//映射public class BugDetail implements java.io.Serializable { // Fields private Long id; private BugProject bugProject; private Long severity; private String tiele; private String reportuser; private Date createdate;
//页面---显示bug_detail表的内容的。
- HTML code
<s:iterator value="all"><tr> td><s:property value="id" /></td> <td><s:property value="tiele" /></td> <td><s:property value="reportuser" /></td> <td><s:property value="createdate" /></td></tr></s:iterator>
这个都能显示。现在我想把<s:property value="id" />这个列换成显示表bug_project 的name字段。
请问我要怎么做
------解决方案--------------------------------------------------------
LZ要好好学下STRUTS2,这种写法都是多余的
ActionContext.getContext().put("pro", iProBiz.findAll());
- Java code
import java.util.ArrayList;import com.opensymphony.xwork2.ActionSupport;public class BugAction extends ActionSupport{ private IBugBiz iBugBiz; private ArrayList<BugDetail> detailList = new ArrayList<BugDetail>(); public void setDetailList(ArrayList<BugDetail> detailList) { this.detailList = detailList; } public ArrayList<BugDetail> getDetailList() { return detailList; } public String select() { detailList = iBugBiz.findAll(); return "selectAll"; } }
------解决方案--------------------------------------------------------
你的查询语句要使用联合查询,才能查到另一个表,你使用的是ssh框架,通过h的映射,就可以知道获得另一个表的id ,但获得不到别的信息
------解决方案--------------------------------------------------------
你的查询语句要使用联合查询,才能查到另一个表,你使用的是ssh框架,通过h的映射,就可以直接获得另一个表的id ,但获得不到别的信息