jstl标签判断不同条件进行不同操作
jstl标签判断不同条件进行不同操作
sannywang 发表于2年前
jstl标签判断不同条件进行不同操作
  • 发表于 2年前
  • 阅读 663
  • 收藏 0
  • 点赞 0
  • 评论 0

移动开发云端新模式探索实践 >>>   

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<script src="${contextPath }/js/jquery-1.7.min.js"></script>
<script src="${contextPath }/js/jquery.min.js"></script>
<script src="${contextPath }/js/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="${contextPath }/css/jquery-ui.min.css" />
<div id="navbar" class="navbar-collapse collapse">
	            <ul class="nav navbar-nav navbar-right">
	                <li><a>[${sessionScope.loginSession.duser }]你好!</a></li>
	                <li><a href="${contextPath }/logout.htm">注销登录</a></li>
	                <c:if test="${sessionScope != null }">
	                <c:forEach items="${sessionScope.invoiceXsfInfosMap }" var="invoiceXsfInfosMap">
                       <c:choose>
                           <c:when test="${invoiceXsfInfosMap.key == '00' && invoiceXsfInfosMap.value == -1}">
                                <li><a><font color="white">云商电子发票余量: </font></a></li>
                           </c:when>
                           <c:when test="${invoiceXsfInfosMap.key == '00' &&  invoiceXsfInfosMap.value <= 10000 }">
                                <li><a><font color="red">(余量不足!)云商电子发票余量:${invoiceXsfInfosMap.value }</font></a></li>
                           </c:when>
                           <c:when test="${invoiceXsfInfosMap.key == '00' && invoiceXsfInfosMap.value > 10000 }">
                                <li><a><font color="white">云商电子发票余量:${invoiceXsfInfosMap.value }</font></a></li>
                           </c:when>
                           <c:when test="${invoiceXsfInfosMap.key == '01' && invoiceXsfInfosMap.value == -1 }">
                                <li><a><font color="white">全球购电子发票余量: </font></a></li>
                           </c:when>
                           <c:when test="${invoiceXsfInfosMap.key == '01' && invoiceXsfInfosMap.value <= 2500 }">
                                <li><a><font color="red">(余量不足!)全球购电子发票余量:${invoiceXsfInfosMap.value }</font></a></li>
                           </c:when>
                           <c:when test="${invoiceXsfInfosMap.key == '01' && invoiceXsfInfosMap.value > 2500 }">
                                <li><a><font color="white">全球购电子发票余量:${invoiceXsfInfosMap.value }</font></a></li>
                           </c:when>
                       </c:choose>
                    </c:forEach>
	                </c:if>
	            </ul>
	        </div>

后台代码:

package com.blemall.controller;

import java.util.HashMap;
import java.util.Map;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.blemall.dao.InvoiceXsfInfoMapper;
import com.blemall.dto.common.ResultDto;
import com.blemall.dto.invoicesys.bw.response.QueryStockResp;
import com.blemall.model.InvoiceXsfInfo;
import com.blemall.service.invoicesys.BWSysService;
import com.blemall.utils.InvoiceXsfInfoConstants;
import com.blemall.utils.StringUtil;

@Controller
@RequestMapping("invoiceXsfInfo")
public class InvoiceXsfInfoController {
	private Map<String, Integer> map;
	private final Logger logger = LoggerFactory
			.getLogger(InvoiceXsfInfoController.class);

	@Autowired
	private InvoiceXsfInfoMapper invoiceXsfInfoMapper;
	@Autowired
	BWSysService bWSysService;

	@RequestMapping("selectElectXsfInfo")
	public String selectElectXsfInfo(HttpServletRequest request,
			HttpServletResponse response) {

		String subject_00 = InvoiceXsfInfoConstants.subject_00;
		String subject_01 = InvoiceXsfInfoConstants.subject_01;
		HttpSession session = request.getSession();

		map = (Map<String, Integer>) session.getAttribute("invoiceXsfInfosMap");
		if (map == null || map.size() == 0) {
			map = new HashMap<String, Integer>();

			setStock2Map(subject_00);
			setStock2Map(subject_01);
			session.setAttribute("invoiceXsfInfosMap", map);
		}
		return InvoiceXsfInfoConstants.IndexView;
	}

	/**
	 *subject 发票主题 00 云商 01 全球购 02 MP 03 纯跨境 
	 */
	private Map<String, Integer> setStock2Map(String subject) {
		String subject_ = subject;
		InvoiceXsfInfo invoiceXsfInfo_ = invoiceXsfInfoMapper
				.selectElectXsfInfo(subject_);
		if (invoiceXsfInfo_ != null) {
			ResultDto resultDto_ = bWSysService.queryStock(
					invoiceXsfInfo_.getTaxpayerid(), invoiceXsfInfo_);
			logger.info(invoiceXsfInfo_.toString());
			if (resultDto_ != null && "0000".equals(resultDto_.getReturnCode()) && resultDto_ instanceof QueryStockResp) {
				//返回的发票份数
				String returnDesc = resultDto_.getReturnDesc();
				if (StringUtil.isNumber(returnDesc)) {
					map.put(subject, Integer.parseInt(returnDesc));
					logger.info("返回的发票剩余数:"+returnDesc);
				} else {
					logger.error("数字转换失败:"+returnDesc);
					map.put(subject, -1);
				}
				logger.info(resultDto_.getReturnDesc());
			} else {
				map.put(subject, -1);
			}
		}
		return map;
	}
}

 

  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 0
博文 55
码字总数 17830
×
sannywang
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: