activity表中task_ID和task表的关系为 CONSTRAINT `FK_activity_task` FOREIGN KEY (`Task_ID`) REFERENCES `task` (`ID`)。
在domian中的代码为:
Task.java
/**
*/
@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
@XmlElement(name = "", namespace = "")
java.util.Set<net.gvsun.domain.Activity> activities;
Activity.java
/**
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({ @JoinColumn(name = "Task_ID", referencedColumnName = "ID") })
@XmlTransient
Task task;
我在jsp里面是这么写的:
<table cellpadding="0" cellspacing="0" id="viewTable" class="tablesorter">
<thead>
<tr>
<th width="15%"><fmt:message key="task.responser.title"/></th>
<th width="20%"><fmt:message key="task.specification.title"/></th>
<th width="10%"><fmt:message key="task.planbegindate.title"/></th>
<th width="10%"><fmt:message key="task.planenddate.title"/></th>
<th width="25%"><fmt:message key="task.projectactivity.title"/></th>
<th width="10%"><fmt:message key="task.createddate.title"/></th>
<th width="10%"><fmt:message key="task.creater.title"/></th>
<th width="8%"><fmt:message key="operation"/></th>
</tr>
</thead>
<tbody>
<c:forEach items="${tasks}" var="current" varStatus="i">
<c:choose>
<c:when test="${(i.count) % 2 == 0}">
<c:set var="rowclass" value="rowtwo"/>
</c:when><c:otherwise>
<c:set var="rowclass" value="rowone"/>
</c:otherwise></c:choose>
<tr class="${rowclass}">
<td>${current.userByResponser.cname} </td>
<td>${current.specification} </td>
<td>
<fmt:formatDate type="date" dateStyle="medium" value="${current.planBeginDate.time}"/>
</td><td>
<fmt:formatDate dateStyle="medium" type="date" value="${current.planEndDate.time}"/>
</td><td>
<c:choose>
<c:when test="${current.activities==null}">
<a class="button" src="${pageContext.request.contextPath}/images/icons/new.gif" /><fmt:message key="activity.title"/></span></a>
</c:when><c:otherwise>
<table cellpadding="0" cellspacing="0" id="viewTable" class="tablesorter">
<thead><th></th><th></th><th></th></thead>
<tbody>
<c:forEach items="${current.activities}" var="activities" varStatus="j">
<c:choose><c:when test="${(j.count) % 2 == 0}">
<c:set var="rowclass" value="rowtwo"/></c:when>
<c:otherwise><c:set var="rowclass" value="rowone"/>
</c:otherwise></c:choose>
<tr class="${rowclass}">
<td>${activities.activityField} : </td>
<td>${activities.userByCreater.cname} : </td>
<td style="color:red;">
<fmt:formatDate dateStyle="medium" type="date" value="${activities.activityTime.time}"/>
</td></tr>
</c:forEach></tbody>
</table>
</c:otherwise>
</c:choose>
</td><td>
<fmt:formatDate pattern="yyyy-MM-dd,HH:mm" type="both" value="${current.createdDate.time}"/>
</td><td>
${current.userByCreater.cname}
</td><td nowrap="nowrap" class="tabletd">
<a title="<fmt:message key="navigation.edit" />" src="${pageContext.request.contextPath}/images/icons/edit.gif" /></a>
<a title="<fmt:message key="navigation.delete" />" onclick='return confirm("<fmt:message key="confirm.if.delete"/>")'><img src="${pageContext.request.contextPath}/images/icons/delete.gif" /></a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
为什么我的数据库中activity表中的task_ID为NULL,而我在jsp里面写${current.activities==null}"时,出现新增按钮,否则就显示一个表格,但是为什么总是显示了一个表格啊?难道这样默认current.activities不为空。
<c:iftest="${ current.activities==null }"></c:if>
isemptyjstl有 isempty判断
${emptyxxxxx}or${!emptyxxxxx} or${notemptyxxxxx}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。