1.Action Class:
public String getResumeNames(){
list=resumeServiceImpl.getResumeNames();
return "success";
}
2.服务类:
public List<DocumentRepository> getResumeNames() {
list=viewResumeDaoImpl.getAllResumeNames();
return list;
}
3.DAO班级:
public List<DocumentRepository> getAllResumeNames() {
try{
SessionFactory sessionFactory=HibernateUtil.buildSessionFactory();
Session session=sessionFactory.openSession();
list=(List<DocumentRepository>)session.createCriteria(DocumentRepository.class).list();
System.out.println(list);
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return list;
}
JSP
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<script type="text/javascript">
function fun(rdval) {
var s = rdval.value;
alert(s);
}
</script>
</head>
<body>
<s:form action="getResume">
<s:iterator value="list">
<input type="radio" name="rid"
value='<s:property value="documentId"/>'
onchange="fun(this)" />
<s:property value="documentName" />
<br />
</s:iterator>
<s:submit value="Display resume"></s:submit>
</s:form>
</body>
</html>
我把list.i中的所有值都给了所有名称前面的视图链接。但是当我点击查看链接时,一个新的jsp在viewResume.jsp中打开名为viewResume.jsp的如何显示简历?
答案 0 :(得分:0)
在行动中
private long rid; // with Setter
private DocumentRepository resume; // with Getter
public String getResume(){
resume=resumeServiceImpl.getResumeById(rid);
return "success";
}
在JSP中
<s:property value="resume.id" />
<s:property value="resume.creationDate" />
<s:property value="resume.dudesname" />
但是,由于您似乎刚开始,我建议您考虑使用Java EE功能,如JPA2(使用Hibernate作为实现)而不是原始Hibernate,completely abandoning the DAO concept。