js中使用EL表达式

分为两种情况,

1、当js代码嵌在jsp页面时,可以使用EL表达式。如:

      <c:if test="${!empty sessionScope.user}">  	
    	<script  type="text/javascript">
	    	require(["dojo/dom-style","dojo/dom-attr"],
	    		function(style,attr){
	    			style.set(dojo.byId("loginorreg"),"display","none");
	    			style.set(dojo.byId("userphoto"),"display","inline");
	    			attr.set("userphoto","src","Image/${sessionScope.user.photo}.jpg");
	    		});
    	</script>
    </c:if>

 2、当js在单独的.js文件中,好像没有找到能行得通的办法。希望有好办法的朋友补充一下。

原文地址:https://www.cnblogs.com/yaoyinglong/p/js-EL.html