實例——創建消息資源文件
hello.jsp使用<bean:message>標簽來輸出文本內容。這些文件來自于Resource Bundle,每個Resource Bundle 都對應一個或多個本地化的消息資源文件。資源文件為
application.properties:
#SDFSALKFJSLAKFLAK
//#為資源文件的注釋
hello.jsp.title=Hello-A first Struts program
對于JSP代碼:
<bean:message key="hello.jsp.title"/>
<bea:message>標簽的key屬性為“hello.jsp.title”,Resource Bundle中與匹配的內容為:
hello.jsp.title=Hello-A first Struts program
因此,以上<bean:message>標簽將把“Hello-A first Struts program”輸出島網頁上。