zoukankan      html  css  js  c++  java
  • 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"/> 
  • 相关阅读:
    P1019 单词接龙
    P1219 八皇后
    Find a way
    P1056 排座椅
    P1067 多项式输出
    关于前缀和,A
    洛谷P1223
    洛谷P1803
    洛谷P1208
    常用方法 Excel转换为DataSet
  • 原文地址:https://www.cnblogs.com/wjup/p/10576083.html
Copyright © 2011-2022 走看看