• jsp页面执行java语法,获取的值在页面调用


    1. 首先在页面头引用用到类的包路径
    2. 写需要执行的java语法
    3. 页面转换引用
    <!-- 引用包路径 -->
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%@ page language="java" import="com.inspur.icpmg.systemMg.vo.UserEntity"%>
    <%@ page language="java" import="com.inspur.icpmg.itss.asset.service.AssetService"%>
    <%@ page language="java" import="com.inspur.icpmg.itss.asset.service.AssetServiceImp"%>
    <%@ page language="java" import="com.inspur.icpmg.util.WebLevelUtil" %>
    <%@ page language="java" import="com.inspur.icpmg.itss.asset.service.AssetInventoryServiceImp" %>
    
    <!-- 执行java语法 -->
    <%
        UserEntity user = WebLevelUtil.getUser(request);
    	String online = user.getUname();
        AssetInventoryServiceImp service =  new AssetInventoryServiceImp();
        String cloudcenterid = service.getcloudcenterIdByCityid(user.getCityid());
    %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <jsp:include page="/web/inc.jsp"></jsp:include>
    <title>xxxx</title>
    </head>
    
    <body>
    
    <!-- 转换 -->
    <script>
        $(document).ready(function() {
    	    cloudcenterid = '<%=cloudcenterid%>';
    	    onlineUser = '<%=online%>';
        });
    
        <!-- 使用 -->
        $('#onlineUser').val(onlineUser);
    </script>
    
    
    <input type="text" id="onlineUser"/> 
  • 相关阅读:
    从零开始webpack4.x(五) js处理
    从零开始webpack4.x(四)样式loader
    从零开始webpack4.x(三)html插件
    从零开始webpack4.x(二)基础
    从零开始webpack4.x(一)介绍
    【转】react和vue渲染流程对比
    css3相关
    html5相关
    this指向
    整数划分问题(递归)
  • 原文地址:https://www.cnblogs.com/wjup/p/10576083.html
Copyright © 2020-2023  润新知