jsp、struts1标签

ligang819350766 2015-01-28 02:19:40
错误: javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method for property: "empno" of bean: "emp"

Caused by: javax.servlet.jsp.JspException: No getter method for property: "empno" of bean: "emp"
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:987)
at com.surekam.platform.util.struts.taglib.WriteTag.doStartTag(WriteTag.java:50)
at org.apache.jsp.emp.empInfo_jsp._jspx_meth_bean_005fwrite_005f0(empInfo_jsp.java:917)
at org.apache.jsp.emp.empInfo_jsp._jspService(empInfo_jsp.java:405)
... 52 more
jsp:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK" %>
<%@ include file="../common/common.jsp" %>
<html:html>
<head>

<title>
员工信息
</title>
<script type="text/javascript" src="<c:url value='/resource/EHM/Base.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resource/jquery/jquery-1.4.2.min.js'/>"></script>
<script type="text/javascript">

var $j=jQuery.noConflict();
EHM.ImportCalendar();
ChangeSkinAPP.Register(function(){ChangeSkin.Import("style.css")});
ChangeSkinAPP.init();


function doQuery(){
document.forms[0].action="find.do";
document.forms[0].submit();
}
</script>

</head>


<body>
<html:form action="find.do">
<table border=0 cellspacing=1 class="form_table" align="center">
<thead>
<tr>
<th colspan="4">员工查询</th>
</tr>
</thead>
<tr>
<th>员工姓名</th>
<td>
<html:text property="emp.eno"></html:text>
</td>
<th>所属部门</th>
<td>
<html:select property="emp.dept">
<html:option value="">--请选择--</html:option>
<logic:iterate id="dept" name="empform" property="depts">
<html:option value="${dept.deptno }">${dept.dname }</html:option>
</logic:iterate>
</html:select>

</td>
</tr>
<tr>
<th>入职时间起</th>
<td width="35%">
<input type="text" id="beginTime" name="startTime" value="${emp.startTime}" readonly="true" style="background-color:#C0C0C0;"/>
<img id="cal-beginTime" src="../resource/images/calbtn.gif" align="absmiddle" border="0"
style="cursor: pointer;"/>
<script type="text/javascript">
Calendar.simMode("beginTime", "cal-beginTime");
</script>
</td>
<th>入职时间止</th>
<td width="35%">
<input type="text" id="endTime" name="endTime" value="${emp.endTime}" readonly="true" style="background-color:#C0C0C0;"/>
<img id="cal-endTime" src="../resource/images/calbtn.gif" align="absmiddle" border="0"
style="cursor: pointer;"/>
<script type="text/javascript">
Calendar.simMode("endTime", "cal-endTime");
</script>
</td>
</tr>
<tr>
<th>最低工资</th>
<td>
<html:text property="emp.minSal"></html:text>
</td>
<th>最高工资</th>
<td>
<html:text property="emp.maxSal"></html:text>
</td>
</tr>
</table>
</html:form>

<table class="btn_table" align="center">
<tr>
<td>
<input type="button" class="btn4" value="查 询" onclick="doQuery();" />
</td>
</tr>
</table>

<html:form action="preAdd.do">
<table id="tb2" border=0 cellspacing=1 class="query_table" align="center">
<thead>
<tr>
<td colspan="7">员工列表</td>
</tr>
</thead>
<tr>
<th>员工编号</th>
<th>所属部门</th>
<th>员工姓名</th>
<th>职位名称</th>
<th>工资</th>
<th>奖金</th>
<th>操作</th>
</tr>

<c:forEach items="${page.results }" var="emp" >
<tr>
<td><c:out value="${emp.eno }"></c:out></td>
<td><c:out value="${emp.dept.dname }"></c:out></td>
<td><c:out value="${emp.ename }"></c:out></td>
<td><c:out value="${emp.job }"></c:out></td>
<td><c:out value="${emp.sal }"></c:out></td>
<td><c:out value="${emp.comm }"></c:out></td>
<td><c:out value="${emp.empno }"></c:out></td>
</tr>
</c:forEach>
<!-- <logic:iterate id="emp" name="empform" property="page.results" > -->
<!-- <tr> -->
<!-- <td><bean:write name="emp" property="empno" ></bean:write></td> -->
<!-- <td><bean:write name="emp" property="dept.dname" ></bean:write></td> -->
<!-- <td><bean:write name="emp" property="ename" ></bean:write></td> -->
<!-- <td><bean:write name="emp" property="job" ></bean:write></td> -->
<!-- <td><bean:write name="emp" property="sal" ></bean:write></td> -->
<!-- <td><bean:write name="emp" property="comm" ></bean:write></td> -->
<!-- <td> -->
<!-- <a href="">详细</a> -->
<!-- <a href="">修改</a> -->
<!-- <a href="">删除</a> -->
<!-- </td> -->
<!-- </tr> -->
<!-- </logic:iterate> -->
<eap:page property="page" emptyTip="没有查到数据。"/>
</table>
<table class="btn_table" align="center">
<tr>
<td>
<input type="submit" class="btn4" value="添 加" />
</td>
</tr>
</table>
</html:form>
</body>
</html:html>

action:
package com.surekam.emp.web.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.MappingDispatchAction;

import com.surekam.emp.model.Emp;
import com.surekam.emp.service.EmpHelper;
import com.surekam.emp.web.form.EmpForm;
import com.surekam.platform.core.container.ApplicationContext;
import com.surekam.platform.core.persistence.Page;

public class EmpAction extends MappingDispatchAction {

private EmpHelper empHelper=(EmpHelper)ApplicationContext.getInstance().getBizComponent("empHelper");

/**
* findEmp列表
*/
public ActionForward find(ActionMapping mapping,ActionForm form,HttpServletRequest request,
HttpServletResponse response){
EmpForm empform=(EmpForm)form;



//设置form中Page
Page page=new Page();
empform.setPage(empHelper.findPage(empform.getEmp()));
empform.setDepts(empHelper.find());


return mapping.findForward("success");
}

/**
* 预添加(跳转到添加页面)
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward preAdd(ActionMapping mapping,ActionForm form,HttpServletRequest request,
HttpServletResponse response){

return null;
}
}

form:
package com.surekam.emp.web.form;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts.action.ActionForm;

import com.surekam.emp.model.Dept;
import com.surekam.emp.model.Emp;
import com.surekam.platform.core.persistence.Page;

public class EmpForm extends ActionForm{
/**
* 分页
*/
Page page=new Page(1,10);

/**
* 员工实例
*/
Emp emp=new Emp();

/**
* 部门实例
*/
Dept dept=new Dept();


/**
* 部门集合
*/
List<Dept> depts=new ArrayList<Dept>();


public Page getPage() {
return page;
}

public void setPage(Page page) {
this.page = page;
}

public Emp getEmp() {
return emp;
}

public void setEmp(Emp emp) {
this.emp = emp;
}

public Dept getDept() {
return dept;
}

public void setDept(Dept dept) {
this.dept = dept;
}

public List<Dept> getDepts() {
return depts;
}

public void setDepts(List<Dept> depts) {
this.depts = depts;
}
}
...全文
337 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ligang819350766 2015-02-03
  • 打赏
  • 举报
回复
各位问题找到了:是我的hql语句 是投影查询 ,结果是list<Object>类型的,所以在jsp中出错了。。。
shixitong 2015-01-29
  • 打赏
  • 举报
回复
private Integer eno; //员工编号和empno有啥区别?为什么不直接写empno?
ligang819350766 2015-01-28
  • 打赏
  • 举报
回复
这个项目用的就是struts1,几年前的架构了,我就学习struts1,在项目上就做了一个练习。Emp类:
package com.surekam.emp.model;

import java.util.Date;

/**
 * 员工类
 * @author Administrator
 *
 */
public class Emp {
	private Integer eno;		//员工编号
	private String ename;	//员工姓名
	private String job;		//职位
	private Integer mgr;
	private Date hiredate;	//入职日期
	private Double sal;		//工资
	private Double comm;	//奖金
	
	private Dept dept;		//部门级联属性
	
	///////////////查询条件/////////////////
	private Date startTime;	//开始时间
	private Date endTime;	//结束时间
	
	private Double maxSal;	//最高工资
	private Double minSal;	//最低工资
	
	
	public Emp(Integer empno, String ename, String job, int mgr, Date hiredate,
			Double sal, Double comm) {
		super();
		this.eno = empno;
		this.ename = ename;
		this.job = job;
		this.mgr = mgr;
		this.hiredate = hiredate;
		this.sal = sal;
		this.comm = comm;
	}
	public Emp() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	
	public String getEname() {
		return ename;
	}
	public void setEname(String ename) {
		this.ename = ename;
	}
	public String getJob() {
		return job;
	}
	public void setJob(String job) {
		this.job = job;
	}
	
	public Date getHiredate() {
		return hiredate;
	}
	public void setHiredate(Date hiredate) {
		this.hiredate = hiredate;
	}
	public Double getSal() {
		return sal;
	}
	public void setSal(Double sal) {
		this.sal = sal;
	}
	public Double getComm() {
		return comm;
	}
	public void setComm(Double comm) {
		this.comm = comm;
	}
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	public Date getStartTime() {
		return startTime;
	}
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	public Double getMaxSal() {
		return maxSal;
	}
	public void setMaxSal(Double maxSal) {
		this.maxSal = maxSal;
	}
	public Double getMinSal() {
		return minSal;
	}
	public void setMinSal(Double minSal) {
		this.minSal = minSal;
	}
	public Integer getMgr() {
		return mgr;
	}
	public void setMgr(Integer mgr) {
		this.mgr = mgr;
	}
	public Integer getEmpno() {
		return eno;
	}
	public void setEmpno(Integer empno) {
		this.eno = empno;
	}
	
	public Integer getEno() {
		return eno;
	}
	public void setEno(Integer eno) {
		this.eno = eno;
	}
	
	
}
追世 2015-01-28
  • 打赏
  • 举报
回复
No getter method for property: "empno" of bean: "emp" emp这个类中没有empno的get方法
shixitong 2015-01-28
  • 打赏
  • 举报
回复
No getter method for property: "empno" of bean: "emp"
桃子_ 2015-01-28
  • 打赏
  • 举报
回复
empno没有get方法?检查下?
Juedaifanghua 2015-01-28
  • 打赏
  • 举报
回复
楼主什么项目?怎么还用struts1

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧