java EL表达式和jstl 取不到值

程序狗MAN 发布于 2016/12/08 16:24
阅读 1K+
收藏 0

收藏!数据建模最全知识体系解读!>>>

<c:forEach  items="${ctrlDetailForm.photoList }" var="item" varStatus="status">
          
             <td style="text-align:center;vertical-align:top;width:20%">
             <INPUT TYPE="checkbox" NAME="${count}" value="${item.photoname}" >
             <INPUT TYPE="hidden" NAME="${count+10}" value="${item.photoname}" >
             <c:out value="${item.photoname}"/><br/>
             
             <img src="<%=webContext %>/image/init/?type=1&key=${item.vId }" class="showImg" style="max-height:80px;max-width:80px"/></td>
         
           <c:set var="count" value="${count +1 }"/>

        </c:forEach>

demo.jsp这个页面能取到值 

我要在另一个界面用 ,复制代码 为什么取不到值,求大神讲解,困扰了好久,解决成功,发微信红包

加载中
0
1
18岁的年华
请问你是怎么得到这个demo.jsp的 怎么返回的 还有前后台交互的方式
0
[
[̲̅V̲̅I̲̅P
看下后台代码
程序狗MAN
程序狗MAN
贴出来了 ,谢谢
0
sduixiang
sduixiang
后台与前台交互的代码贴出来,是放session里了,还是作为参数只发到这个页面了
sduixiang
sduixiang
回复 @程序狗MAN : <c:forEach items="${ctrlDetailForm }" var="items" varStatus="status"> <c:forEach items="${items.photoList }" var="item" varStatus="status"> 你试试 有时候先拿session里的值,再遍历这个
sduixiang
sduixiang
@程序狗MAN 回复@程序狗MAN : <c:forEach items="${ctrlDetailForm.photoList }" var="items" varStatus="status"> <c:forEach items="${items.photoList }" var="item" varStatus="status"> ...
程序狗MAN
程序狗MAN
后台代码,贴出来,帮我看看。谢谢
0
看那条狗
看那条狗
先看后台有没有传数据,再看看变量名对应了没。
程序狗MAN
程序狗MAN
后台代码,贴出来,谢谢
0
程序狗MAN
程序狗MAN
@Controller
@RequestMapping(value = "/ctrlDetail")
public class MainCtrlDetailController extends CommonController {
    
    /**
     * 主控车辆信息详细Mapper
     */
    @Autowired
    private SearchCtrlDetailMapper searchCtrlDetailMapper;
    
    /**
     * 用户信息Mapper
     */
    @Autowired
    private IcUserMapper icUserMapper;
    
    /**
     * 照片Mapper
     */
    @Autowired
    private IcInsRecordPhotoMapper icInsRecordPhotoMapper;
    
    /**
     * 初期表示
     * 
     * @param request HttpServletRequest
     * @return 视图
     * @throws Exception 异常
     */
    @RequestMapping(value = "/init", method = {
        RequestMethod.POST, RequestMethod.GET
    })
    public ModelAndView init(HttpServletRequest request) throws Exception {
        ModelAndView mv = new ModelAndView();
        // checkLogin(request.getSession());
        CtrlDetailForm form = new CtrlDetailForm();
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("vid", request.getParameter("pkId"));
        form.setJdcjbxx(searchCtrlDetailMapper.selectJdcjbxx(param));
        param = new HashMap<String, Object>();
        param.put("vid", request.getParameter("vId"));
        param.put("pkId", request.getParameter("pkId"));
        List<IcInsRecord> icInsRecordList = searchCtrlDetailMapper.selectIcInsRecord(param);
        IcUser userSession = (IcUser) request.getSession().getAttribute("USERINFO");
        if (icInsRecordList != null && icInsRecordList.size() > 0) {
            form.setIcInsRecord(getRecord(icInsRecordList));
            Map<String, Object> paramPhoto = new HashMap<String, Object>();
            paramPhoto.put("insPk", form.getIcInsRecord().getvId());
            paramPhoto.put("vid", form.getIcInsRecord().getPkId());
            form.setPhotoList(searchCtrlDetailMapper.selectIcInsRecordPhoto(paramPhoto));
            IcUser user =
                icUserMapper.selectByPrimaryKey(icInsRecordList.get(0).getInsertUser());
            if (user != null) {
                form.setChaYanYuan(user.getName());
            }
            if ("7".equals(form.getIcInsRecord().getCheckStatus()) && icInsRecordList.size() > 1) {
                // 复检合格
                user =
                    icUserMapper
                        .selectByPrimaryKey(icInsRecordList.get(icInsRecordList.size() - 1).getInsertUser());
                form.setFujianUser(user.getName());
                form.setFujianKey(user.getLoginId());
            }
            if (user != null) {
                form.getZl().addAll(CarSettingListener.getSetting(user.getDepartmentId()).getZl());
                String dId = user.getDepartmentId();
                while (dId.length() > 0) {
                    dId = dId.substring(0, dId.length() - 2);
                    if (dId.length() == 0) {
                        // admin 设置的资料 无部门ID
                        form.getZl().addAll(CarSettingListener.getSetting(null).getZl());
                    } else {
                        form.getZl().addAll(CarSettingListener.getSetting(dId).getZl());
                    }
                    
                }
                mv.addObject("monitor", CarSettingListener.getMonitorInfo(user.getDepartmentId()));
                mv.addObject("editFlg", user.getDepartmentId().equals(userSession.getDepartmentId()));
                mv.addObject("dyInfo", CarSettingListener.getDyInfo(user.getDepartmentId()));
            }
        }
        mv.addObject("ctrlDetailForm", form);
        mv.setViewName("/control/ctrlDetail");
        return mv;
    }
    后台的代码
0
程序狗MAN
程序狗MAN
都已经 mv.addObject("ctrlDetailForm", form); 应该存的没问题吧,别的界面都能取到,我新建个界面就取不到,不知道为什么,<%@ page isELIgnored="false" %> 也加了,我在jsp里不${ctrlDetailForm.XXX}就能取到值吗
0
程序狗MAN
程序狗MAN

<form:form id="ctrlDetailForm" commandName="ctrlDetailForm" name="ctrlDetailForm" method="post" action="/Car/ctrlDetail/img" style="float: left;">      <script>


</form:form>
<!-- 以下是机动车审核显示层代码 -->
  <div id="light" class="white_content">
        
        <h1 align="center" style="margin-bottom: 5px">机动车审核</h1>
    <form action="http://localhost:8088/Car/jdc_insert.jsp" method="POST">
  <div style="text-align:center">
                   
 <table width="50%" border="1" cellpadding="3" cellspacing="0" style="width: 50%;margin:auto">
  <tr >
      <input type="hidden" name="lsh" value="${ctrlDetailForm.jdcjbxx.zclsh}">
      <input type="hidden" name="id" value="${sessionScope.USERINFO.name }">
      <input type="hidden" name="vId" value="${ctrlDetailForm.icInsRecord.vId}">
      <input type="hidden" name="pkId" value="${ctrlDetailForm.icInsRecord.pkId}">
 <td colspan="2" align="right" bgcolor="#CCCCFF">查验项目&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <input type="button" onclick="ck(true)" value="全选"><input type="button" onclick="ck(false)" value="取消全选"></td>  
  </tr>
  <tr>
 <td width="49%" align="left" ><INPUT TYPE="checkbox" NAME="a" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.cheLiangShiBieDaiHao == '1' }"><font color="RED">01.车辆识别代码</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.cheLiangShiBieDaiHao == '0' }"><font color="RED">01.车辆识别代码</font></c:when><c:otherwise>01.车辆识别代码</c:otherwise></c:choose></td>  
 <td width="51%" align="left"><INPUT TYPE="checkbox" NAME="b" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.engineTypeFlag == '1' }"><font color="RED">02.发动机型号/号码</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.engineTypeFlag == '0' }"><font color="RED">02.发动机型号/号码</font></c:when><c:otherwise>02.发动机型号/号码</c:otherwise></c:choose></td>                                                                                
  </tr>
  <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="c" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.vehicleBrandFlag == '1' }"><font color="RED">03.车辆品牌/型号</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.vehicleBrandFlag == '0' }"><font color="RED">03.车辆品牌/型号</font></c:when><c:otherwise>03.车辆品牌/型号</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="d" value="1" >
 
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.carColorFlag == '1' }"><font color="RED">04.车身颜色</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.carColorFlag == '0' }">04.车身颜色</c:when></c:choose>
 </td>                                                                                
  </tr>
  <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="e" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.seatsFlag == '1' }"><font color="RED">05.核定载人数(学生/成人)</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.seatsFlag == '0' }"><font color="RED">05.核定载人数(学生/成人)</font></c:when></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="f" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.carTypeFlag == '1' }"><font color="RED">06.车辆类型</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.carTypeFlag == '0' }"><font color="RED">06.车辆类型</font></c:when></c:choose></td>                                                                                
  </tr>
  <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="g" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.cheLiangWaiGuan == '1' }"><font color="RED">07.号牌/车辆外观形状</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.cheLiangWaiGuan == '0' }"><font color="RED">07.号牌/车辆外观形状</font></c:when><c:otherwise>07.号牌/车辆外观形状</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="h" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.wheelBase == '1' }"><font color="RED">08.轮胎完好情况</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.wheelBase == '0' }"><font color="RED">08.轮胎完好情况</font></c:when><c:otherwise>08.轮胎完好情况</c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="i" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.warningSignFlag == '1' }"><font color="RED">09.安全带、三角警告牌</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.warningSignFlag == '0' }"><font color="RED">09.安全带、三角警告牌</font></c:when><c:otherwise>09.安全带、三角警告牌</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="j" value="1" >
<c:choose><c:when test="${(ctrlDetailForm.icInsRecord.waiKuoChiCunFlag == '0') or (ctrlDetailForm.icInsRecord.outCheckFlg == '0')}"><font color="RED">10.外廓尺寸、轴数、轴距</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.waiKuoChiCunFlag == '1' or ctrlDetailForm.icInsRecord.outCheckFlg =='1' }"><font color="RED">10.外廓尺寸、轴数、轴距</font></c:when><c:otherwise>10.外廓尺寸、轴数、轴距</c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="k" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.zhengBeiZhiLiangFlag == '1' }"><font color="RED">11.整备质量</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.zhengBeiZhiLiangFlag == '0' }"><font color="RED">11.整备质量</font></c:when><c:otherwise>11.整备质量</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="l" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.lunTaiGuiGe == '1' }"><font color="RED">12.轮胎规格</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.lunTaiGuiGe == '0' }"><font color="RED">12.轮胎规格</font></c:when><c:otherwise>12.轮胎规格</c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="m" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.fangHuZhuangZhi == '1' }"><font color="RED">13.侧后部防护装置</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.fangHuZhuangZhi == '0' }"><font color="RED">13.侧后部防护装置</font></c:when><c:otherwise>13.侧后部防护装置</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="n" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.fanGuangBiaoShi == '1' }"><font color="RED">14.车身反光标识和车辆尾部标志板、喷涂</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.fanGuangBiaoShi == '0' }"><font color="RED">14.车身反光标识和车辆尾部标志板、喷涂</font></c:when><c:otherwise>14.车身反光标识和车辆尾部标志板、喷涂</c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="o" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.mieHuoQi == '1' }"><font color="RED">15.灭火器</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.mieHuoQi == '0' }"><font color="RED">15.灭火器</font></c:when><c:otherwise>15.灭火器</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="p" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.xingShiJiLuZhuangZhi == '1' }"><font color="RED">16.行驶记录装置、车内外录像监控装置</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.xingShiJiLuZhuangZhi == '0' }"><font color="RED">16.行驶记录装置、车内外录像监控装置</font></c:when><c:otherwise>16.行驶记录装置、车内外录像监控装置</c:otherwise></c:choose></td>                                                                                
  </tr>
  
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="q" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.yingJiChuKou == '1' }"><font color="RED">17.应急出口/应急锤、乘客门</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.yingJiChuKou == '0' }"><font color="RED">17.应急出口/应急锤、乘客门</font></c:when><c:otherwise>17.应急出口/应急锤、乘客门</c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="r" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.waiBuBiaoShi == '1' }"><font color="RED">18.外文/标识文字、喷涂</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.waiBuBiaoShi == '0' }"><font color="RED">18.外文/标识文字、喷涂</font></c:when><c:otherwise>18.外文/标识文字、喷涂</c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="s" value="1" >
<c:choose><c:when test="${ctrlDetailForm.icInsRecord.biaoShiDengJu == '1' }"><font color="RED">19.标志灯具、警报器</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.biaoShiDengJu == '0' }"><font color="RED">19.标志灯具、警报器</font></c:when><c:otherwise>19.标志灯具、警报器</c:otherwise></c:choose> </td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="t" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.jianYanHeGeZhengMing == '1' }"><font color="RED">20.检验合格证明</font></c:when><c:when test="${ctrlDetailForm.icInsRecord.jianYanHeGeZhengMing == '0' }"><font color="RED">20.检验合格证明</font></c:when><c:otherwise>20.检验合格证明</c:otherwise></c:choose></td>                                                                                
  </tr>
  <tr>
     <td colspan="2" align="center" bgcolor="#CCCCFF">外廓检查</td>
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="u" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.outLength ==null }">01.外廓长</c:when><c:otherwise><font color="RED">01.外廓长</font></c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="v" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.outWidth == '' }">02.外廓宽</c:when><c:otherwise><font color="RED">02.外廓宽</font></c:otherwise></c:choose></td>                                                                                
  </tr>
   <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="w" value="1" >
 <c:choose><c:when test="${ctrlDetailForm.icInsRecord.outHeight == null }">03.外廓高</c:when><c:otherwise><font color="RED">03.外廓高</font></c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="x" value="1" >
<c:choose><c:when test="${ctrlDetailForm.icInsRecord.innerHeight == null }">04.内廓长</c:when><c:otherwise><font color="RED">04.内廓长</font></c:otherwise></c:choose></td>                                                                                
  </tr>
  <tr>
 <td align="left"><INPUT TYPE="checkbox" NAME="y" value="1" >
<c:choose><c:when test="${ctrlDetailForm.icInsRecord.innerHeight == null }">05.内廓宽</c:when><c:otherwise><font color="RED">05.内廓宽</font></c:otherwise></c:choose></td>  
 <td align="left"><INPUT TYPE="checkbox" NAME="z" value="1" >
<c:choose><c:when test="${ctrlDetailForm.icInsRecord.innerHeight == null }">06.内廓高</c:when><c:otherwise><font color="RED">06.内廓高</font></c:otherwise></c:choose></td>                                                                                
  </tr>
  
  <tr>
    <td colspan="2"  bgcolor="#CCCCFF" align="center">车辆照片</td>
  </tr>
  
  <tr>
       <td colspan="2"    align="center">
        <table width="95%" border="1" >
             <tr>
              <c:set var="count" value="0"/>
        <c:forEach  items="${ctrlDetailForm.photoList }" var="item" varStatus="status">
          
             <td style="text-align:center;vertical-align:top;width:20%">
             <INPUT TYPE="checkbox" NAME="${count}" value="${item.photoname}" >
             <INPUT TYPE="hidden" NAME="${count+10}" value="${item.photoname}" >
             <c:out value="${item.photoname}"/><br/>
             
             <img src="<%=webContext %>/image/init/?type=1&key=${item.vId }" class="showImg" style="max-height:80px;max-width:80px"/></td>
         
           <c:set var="count" value="${count +1 }"/>
        </c:forEach>
        <INPUT type="hidden" NAME="shu" value="${count}" > 
          </tr>
      </table>
       </td>
  </tr>
  
 <tr>
    <td colspan="2"  bgcolor="#CCCCFF" align="center">备注</td>
  </tr>
 <tr>
   <td colspan="2" ><textarea name="bz" cols="100" rows="5"></textarea></td>
 </tr>
 
 <tr>
    <td colspan="2" align="right"><font color="RED">1.红色代表经过查验的  2.有不合格的先勾选,然后点击不通过按钮,都合格直接点击通过即可</font>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    </br>
    <input type="submit" style="background: #99FFFF"   value="不通过" > <input type="button" style="background: #99FFFF"   value="关闭" onclick = "document.getElementById('light').style.display='none'">
<input type="submit" style="background: #99FFFF"   value="通过" ></td>
  </tr>
</table>
</div>
</form> 
</div>
<!-- 以上是机动车审核显示层代码 -->
 

在这个界面EL取值什么都正常,以前点击审核时DIV弹出层做的,EL能获取到值和图片,现在要给他变成点击在新页面打开显示原来DIV里的东西,我就新建个JSP,但在这个JSP里用EL取不到值

返回顶部
顶部