为什么在jsp页面上获取的常量值都为空?
claim_voucher_deal.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ page import="com.yuan.oa.global.Constant" %> < jsp:include page = "top.jsp" /> < section id = "content" class = "table-layout animated fadeIn" > < div class = "tray tray-center" > < div class = "content-header" > < h2 > 待处理报销单 </ h2 > < p class = "lead" ></ p > </ div > < div class = "admin-form theme-primary mw1000 center-block" style = "padding-bottom: 175px;" > < div class = "panel heading-border" > < div class = "panel-menu" > < div class = "row" > < div class = "hidden-xs hidden-sm col-md-3" > < div class = "btn-group" > < button type = "button" class = "btn btn-default light" > < i class = "fa fa-refresh" ></ i > </ button > < button type = "button" class = "btn btn-default light" > < i class = "fa fa-trash" ></ i > </ button > < button type = "button" class = "btn btn-default light" > < i class = "fa fa-plus" onclick = "javascript:window.location.href='/claim_voucher/to_add';" ></ i > </ button > </ div > </ div > < div class = "col-xs-12 col-md-9 text-right" > < div class = "btn-group" > < button type = "button" class = "btn btn-default light" > < i class = "fa fa-chevron-left" ></ i > </ button > < button type = "button" class = "btn btn-default light" > < i class = "fa fa-chevron-right" ></ i > </ button > </ div > </ div > </ div > </ div > < div class = "panel-body pn" > < table id = "message-table" class = "table admin-form theme-warning tc-checkbox-1" > < thead > < tr class = "" > < th class = "text-center hidden-xs" >Select</ th > < th class = "hidden-xs" >事由</ th > < th >状态</ th > < th class = "hidden-xs" >创建人</ th > < th class = "hidden-xs" >金额</ th > < th class = "text-center" >创建时间</ th > < th >操作</ th > </ tr > </ thead > < tbody > < c:forEach items = "${list}" var = "cv" > < tr class = "message-unread" > < td class = "hidden-xs" > < label class = "option block mn" > < input type = "checkbox" name = "mobileos" value = "FR" > < span class = "checkbox mn" ></ span > </ label > </ td > < td >${cv.cause}</ td > < td class = "hidden-xs" > < span class = "badge badge-warning mr10 fs11" >${cv.status}</ span > </ td > < td >${cv.creater.name}</ td > < td class = "text-center fw600" >${cv.totalAmount}</ td > < td >< spring:eval expression = "cv.createTime" /></ td > < td > //为何这里的常量值都为空(如Constant.CLAIMVOUCHER_CREATED是个空字符串) < c:if test = "${cv.status==Constant.CLAIMVOUCHER_CREATED || cv.status==Constant.CLAIMVOUCHER_BACK}" > < a href = "/claim_voucher/details?id=${cv.id}" >修改</ a > < a href = "/claim_voucher/details?id=${cv.id}" >提交</ a > </ c:if > < c:if test = "${cv.status==Constant.CLAIMVOUCHER_SUBMIT || cv.status==Constant.CLAIMVOUCHER_RECHECK}" > < a href = "/claim_voucher/details?id=${cv.id}" >打回</ a > < a href = "/claim_voucher/details?id=${cv.id}" >审核</ a > </ c:if > < c:if test = "${cv.status==Constant.CLAIMVOUCHER_APPROVED}" > < a href = "/claim_voucher/details?id=${cv.id}" >打款</ a > </ c:if > < a href = "/claim_voucher/details?id=${cv.id}" >${Constant.CLAIMVOUCHER_CREATED}详细信息${cv.status}</ a > </ td > </ tr > </ c:forEach > </ tbody > </ table > </ div > </ div > </ div > </ div > </ section > < jsp:include page = "bottom.jsp" /> |
Constant.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | package com.yuan.oa.global; import java.util.ArrayList; import java.util.List; //常量类 public class Constant { //职务 public static final String POST_STAFF= "员工" ; public static final String POST_FM= "部门经理" ; public static final String POST_GM= "总经理" ; public static final String POST_CASHIER= "财务" ; //职务集合 public static List<String> getPosts() { List<String> list= new ArrayList<String>(); list.add(POST_STAFF); list.add(POST_FM); list.add(POST_GM); list.add(POST_CASHIER); return list; } //费用类型 public static List<String> getItems() { List<String> list= new ArrayList<String>(); list.add( "交通" ); list.add( "餐饮" ); list.add( "住宿" ); list.add( "办公" ); list.add( "其他" ); return list; } //报销单状态(不要忘了加final) public static final String CLAIMVOUCHER_CREATED= "新创建" ; public static final String CLAIMVOUCHER_SUBMIT= "提交" ; public static final String CLAIMVOUCHER_APPROVED= "已审核" ; public static final String CLAIMVOUCHER_BACK= "已打回" ; public static final String CLAIMVOUCHER_TEAMINATED= "已终止" ; public static final String CLAIMVOUCHER_RECHECK= "待复审" ; public static final String CLAIMVOUCHER_PAID= "已打款" ; //审核额度 public static final double LIMIT_CHECK= 5000 ; //处理方式(处理状态):不要忘了加final public static final String DEAL_CREATED= "创建" ; public static final String DEAL_SUBMIT= "提交" ; public static final String DEAL_UPDATE= "修改" ; public static final String DEAL_BACK= "打回" ; public static final String DEAL_REJECT= "拒绝" ; public static final String DEAL_PASS= "通过" ; public static final String DEAL_PAID= "打款" ; } |
33
收起
正在回答
5回答
你的现象好诡异,我测了一下也是能正常显示的。。。。我的是tomcat8.5 , jdk1.8
源自我心
2018-05-24 18:53:18
1 | ${Constant.CLAIMVOUCHER_CREATED} |
1 | < c:out value = "${Constant.CLAIMVOUCHER_CREATED}" /> |
我使用了这两种方法还是没有取出常量值,显示的依然为空。
我这里的把常量值直接改成字符串,相应的这些链接是可以显示的,比如
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < td > < c:out value = "${Constant.CLAIMVOUCHER_CREATED}" /> < c:if test = "${cv.status=='新创建' || cv.status=='已打回'}" > < a href = "/claim_voucher/to_update?id=${cv.id}" >修改</ a > < a href = "/claim_voucher/submit?id=${cv.id}" >提交</ a > </ c:if > < c:if test = "${cv.status=='已提交' || cv.status=='待复审'}" > < a href = "/claim_voucher/to_check?id=${cv.id}" >审核</ a > </ c:if > < c:if test = "${cv.status=='已审核'}" > < a href = "/claim_voucher/to_check?id=${cv.id}" >打款</ a > </ c:if > < a href = "/claim_voucher/details?id=${cv.id}" >详细信息</ a > </ td > |
但是使用常量值就不行了
SSM主流框架入门与综合项目实战2018版
- 参与学习 人
- 提交作业 205 份
- 解答问题 4317 个
Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧