<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ include file="/WEB-INF/tld/taglibs.jsp"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <% String userAgent = request.getHeader("User-Agent"); String deviceOS = ""; if(userAgent.indexOf("Android")>0 || userAgent.indexOf("iPhone")>0){ deviceOS = "phone"; } %> <title>开机启动</title> </head> <body> <%= userAgent%> <%= deviceOS%> <center> <c:if test='<%=deviceOS == "phone" %>'> <img alt="" src="${img}" width="80%"/> </c:if> <c:if test='<%=deviceOS == "" %>'> <img alt="" src="${img}" /> </c:if> </center> </body> </html>
注意el表达式中的双引号 '<%= deviceOS == "phone" %>'