解决方案 »
- 郁闷的问题,急需解决 Could not find action or result
- struts2导出excel困扰好几天了,恳求相助!
- struts2上传文件的显示问题
- xfire+tomcat 开发WebService,通过接口传递byte[],请高手指教
- 登录验证
- jsp是否可以实现tcp或udp的通讯?
- COM+组件问题
- 如何让客户端直接读取服务器端的excell文件
- 我用的tomcat服务器,在root目录明明有index.jsp文件,但我用http://localhost:8080/index.jsp就是不能访问
- 救命!中毒了!?以前很正常呀!今晚运行JSP时不知道什么东西给我的JSP文件的末尾加了一段vbscript代码,还莫名奇妙地启动java plug-in到任务
- 使用struts-convention时报错
- dwr 与spring整合问题
private String idCard;
private String plateno;
private String epType;
private Date illegalTime;
private String address;
private String illegalAction;
private Long illegalType;
private String source;
private Double fine;
private Integer points;
private Long deptid;
private String re;
public Long getOffenceID() {
return offenceID;
} public void setOffenceID(Long offenceID) {
this.offenceID = offenceID;
} public String getIdCard() {
return idCard;
} public void setIdCard(String idCard) {
this.idCard = idCard;
} public String getPlateno() {
return plateno;
} public void setPlateno(String plateno) {
this.plateno = plateno;
}
public String getEpType() {
return epType;
} public void setEpType(String epType) {
this.epType = epType;
} public Date getIllegalTime() {
return illegalTime;
} public void setIllegalTime(Date illegalTime) {
this.illegalTime = illegalTime;
} public String getAddress() {
return address;
} public void setAddress(String address) {
this.address = address;
} public String getIllegalAction() {
return illegalAction;
} public void setIllegalAction(String illegalAction) {
this.illegalAction = illegalAction;
} public Long getIllegalType() {
return illegalType;
} public void setIllegalType(Long illegalType) {
this.illegalType = illegalType;
} public String getSource() {
return source;
} public void setSource(String source) {
this.source = source;
} public Double getFine() {
return fine;
} public void setFine(Double fine) {
this.fine = fine;
} public Integer getPoints() {
return points;
} public void setPoints(Integer points) {
this.points = points;
} public String getRe() {
return re;
} public void setRe(String re) {
this.re = re;
} public Long getDeptid() {
return deptid;
} public void setDeptid(Long deptid) {
this.deptid = deptid;
}}Sql语句 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="Mapper.Offence">
<resultMap id="get-offence-result" type="offenceInfo">
<result property="offenceID" column="offenceID" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="idCard" column="idCard" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="plateno" column="plateno" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="epType" column="epType" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="illegalTime" column="illegalTime" jdbcType="DATE" javaType="java.sql.Timestamp"/>
<result property="address" column="address" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="illegalAction" column="illegalAction" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="illegalType" column="illegalType" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="source" column="source" jdbcType="VARCHAR" javaType="java.lang.String"/>
<result property="fine" column="fine" jdbcType="DECIMAL" javaType="java.lang.Double"/>
<result property="points" column="points" jdbcType="INTEGER" javaType="java.lang.Integer"/>
<result property="deptid" column="deptid" jdbcType="BIGINT" javaType="java.lang.Long"/>
<result property="re" column="re" jdbcType="VARCHAR" javaType="java.lang.String"/>
</resultMap>
<sql id="whereOffence">
<where>
<if test="driver.drivername != null">
<![CDATA[
and idCard in (select id_card from jy_fingerprint.driver where name like '%${driver.drivername}%')
]]>
</if>
<if test="offence.plateno != null">
and plateno = #{offence.plateno}
</if>
<if test="offence.epType != null">
and epType = #{offence.epType}
</if>
<if test="offence.illegalType != null">
<![CDATA[
and illegalType = #{offence.illegalType}
]]>
</if>
<if test="dateFrom != null">
<![CDATA[
and illegalTime > #{dateFrom}
]]>
</if>
<if test="dateTo != null">
<![CDATA[
and illegalTime <= #{dateTo}
]]>
</if>
<if test="offence.deptid != null">
<![CDATA[
and deptid in (select node.id from jy_unpn.dept as node, jy_unpn.dept as parent
where node.lft between parent.lft and parent.rgt and parent.id=#{offence.deptid})
]]>
</if>
</where>
</sql>
<insert id="insertOffence" parameterType="offenceInfo" keyProperty="offenceID" useGeneratedKeys="true">
<![CDATA[
insert into jy_unpn.Tbl_OffenceInfo (idCard,plateno,epType,illegalTime,address,illegalAction,illegalType,source,fine,points,deptid,re)
values (#{idCard},#{plateno},#{epType},#{illegalTime},#{address},#{illegalAction},#{illegalType},#{source},#{fine},#{points},#{deptid},#{re})
]]>
</insert>
<update id="updateOffence" parameterType="offenceInfo">
<![CDATA[
update jy_unpn.Tbl_OffenceInfo
]]>
<set>
<if test="idCard != null">
idCard = #{idCard},
</if>
<if test="plateno != null">
plateno = #{plateno},
</if>
<if test="epType != null">
epType = #{epType},
</if>
<if test="illegalTime != null">
illegalTime = #{illegalTime},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="illegalAction != null">
illegalAction = #{illegalAction},
</if>
<if test="illegalType != null">
illegalType = #{illegalType},
</if>
<if test="source != null">
source = #{source},
</if>
<if test="fine != null">
fine = #{fine},
</if>
<if test="points != null">
points = #{points},
</if>
<if test="deptid != null">
deptid = #{deptid},
</if>
<if test="reamrk != null">
reamrk = #{reamrk}
</if>
</set>
where offenceID = #{offenceID}
</update>
<delete id="deleteOffence" parameterType="offenceInfo">
<![CDATA[
delete from jy_unpn.Tbl_OffenceInfo where offenceID = #{offenceID}
]]>
</delete>
<select id="getOffenceById" parameterType="offenceInfo" resultType="offenceInfo">
<![CDATA[
select offenceID,idCard,plateno,epType,illegalTime,address,illegalAction,illegalType,source,fine,points,deptid,re from jy_unpn.Tbl_OffenceInfo
where offenceID = #{offenceID}
]]>
</select>
<select id="getOffenceCount" parameterType="offenceVO" resultType="java.lang.Integer">
<![CDATA[
select count(*) from jy_unpn.Tbl_OffenceInfo
]]>
<include refid="whereOffence"/>
</select>
<select id="getOffenceList" parameterType="offenceVO" resultMap="get-offence-result">
<include refid="Common.PagePrefix" />
<![CDATA[
select offenceID,idCard,plateno,epType,illegalTime,address,illegalAction,illegalType,source,fine,points,deptid,re from jy_unpn.Tbl_OffenceInfo
]]>
<include refid="whereOffence"/>
order by illegalTime desc
<include refid="Common.PageSuffix" />
</select>
</mapper>执行Servicepublic class OffenceService implements IOffenceService {
@Resource(name="offenceDao")
private IOffenceDao offenceDao;
@Resource(name="deptDao")
private IDeptDao deptDao;
@Resource(name="driverDao")
private IDriverDao driverDao;
@Override
public void saveOffence(OffenceInfo offence) throws Exception {
offenceDao.saveOffence(offence);
} @Override
public void updateOffence(OffenceInfo offence) throws Exception {
offenceDao.updateOffence(offence);
} @Override
public void deleteOffence(OffenceInfo offence) throws Exception {
offenceDao.deleteOffence(offence);
} @Override
public OffenceInfo getOffenceById(OffenceInfo offence) throws Exception {
return offenceDao.getOffenceById(offence);
} @Override
public int getOffenceCount(OffenceVO offenceVO) throws Exception {
return offenceDao.getOffenceCount(offenceVO);
} @Override
public List<OffenceVO> getOffenceList(OffenceVO offenceVO)
throws Exception {
List<OffenceInfo> alist =offenceDao.getOffenceList(offenceVO);
List<OffenceVO> volist = null;
if (alist != null &&alist.size()>0 ) {
volist = new ArrayList<OffenceVO>();
for(OffenceInfo off : alist){
OffenceVO offvo = new OffenceVO();
offvo.setOffence(off);
//判断部门是否为空
if(off.getDeptid() != null){
Dept dept = new Dept();
dept.setDeptid(off.getDeptid());
dept = deptDao.getDeptById(dept);
offvo.setDept(dept);
}
//查询驾驶员
String idCard = off.getIdCard();
if(StringUtils.isNotBlank(idCard))
{
Driver driver = new Driver();
driver.setId_card(idCard);
driver = driverDao.getDriverByIdCard(driver);
offvo.setDriver(driver);
}
volist.add(offvo);
}
}
return volist;
}
}
2. 如果是用struts的话, 那么你应该也有在前端或者某个地方给他赋值了, 然后在action中set、get实体类的对象, 然后通过对象的get方法就可以取到该值了
hidden.put("offenceVO.offence.offenceID", "违章信息ID");
this.getRequest().setAttribute("hidden", hidden);
他是在这里把offenceID传到页面的