JSTL标签

1  fmt:message标签:

可以输出资源文件里的key对应的value.而且还可以使用占位符。

1>属性文件:message.properties:

title=SpringApp
heading=Hello :: SpringApp
greeting=Greetings, it is now

<!--占位符={0},{1} -->可以通过fmt:mesage的子标签如:

<fmt:param>
        <c:out value="A" /> 
</fmt:param>
<fmt:param>

        <c:out value="B" />
</fmt:param>

2>jsp页面:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title><fmt:message key="title"/></title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   

  </head>
 
  <body>
  <h1><fmt:message key="heading"/></h1>
 <p><fmt:message key="greeting"/><c:out value="${model.now}"/></p>
 <h3>Products</h3>
 <c:forEach items="${model.products}" var="product">
 <c:out value="${product.description}"/> <i>$<c:out value="${product.price}"/></i><br><br>
 </c:forEach>
  </body>
</html>

3>web.xml文件:

 <context-param>  
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <!-- message.properties文件的文件名 --> 
        <param-value>message</param-value>  
</context-param>

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(java,html,jsp,File,import,include)