1.jsp:
<select class=" z9" name="sstage" id="sstage">
<c:forEach items="${sstagelist}" var="a">
<option value="${a.ck}"
<c:if test="${infoproject.sstage==a.ck}"> selected="selected"</c:if>>${a.cv}</option>
</c:forEach>
</select>
2.WebController:
Map<String, Object> pmap = new HashMap<String, Object>();
pmap.clear();
pmap.put("cfield", "SSTAGE");
model.addAttribute("sstagelist", commonsService.getCKVList(pmap));
3.CommonsService
package com.yuyoukj.service;
import java.util.List;
import java.util.Map;
import com.yuyoukj.model.nch.CKV;
public interface CommonsService {
public List<CKV> getCKVList(Map<String, Object> pmap);
}
4.CommonsServiceImpl
package com.yuyoukj.service.impl;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yuyoukj.mapper.nch.CKVMapper;
import com.yuyoukj.model.nch.CKV;
import com.yuyoukj.service.CommonsService;
@Service
public class CommonsServiceImpl implements CommonsService {
private static Logger log = Logger.getLogger(CommonsServiceImpl.class);
@Autowired
private CKVMapper ckvMapper;
@Override
public List<CKV> getCKVList(Map<String, Object> pmap) {
return ckvMapper.getCKVList(pmap);
}
}
5.CKVMapper
<?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="com.yuyoukj.mapper.nch.CKVMapper">
<resultMap id="CKVResult" type="com.yuyoukj.model.nch.CKV">
<result property="ck" column="ck" />
<result property="cv" column="cv" />
</resultMap>
<select id="getCKVList" parameterType="java.util.HashMap" resultMap="CKVResult">
SELECT ckey as ck, cvalue as cv
FROM conf_cconfig
WHERE 1 = 1
<if test="cfield != null">
AND cfield = #{cfield}
</if>
</select>
</mapper>