आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
JSTL - jstl formatting message

<prefix:message> tag ये internationalized message display करने के लिए इस्तेमाल किया जाता है |


Syntax for <prefix:message> tag in JSTL

<prefix:message key="key_name" bundle="bundle_variable" var="variable_name" scope="scope_name"/>

Attributes for <prefix:message> tag in JSTL

key : Optional. यहाँ पर value को display करने के लिए key दी जाती है | यह key resource bundle में से key-value की pair से ली जाती है |

bundle : इस्तेमाल किया जानेवाला resource bundle दिया जाता है |

var : यहाँ पर variable name दिया जाता है |

scope : यहाँ पर scope दिया जाता है |


Example for <prefix:message> Tag in JSTL

Sample.java
package myPackage;  
import java.util.ListResourceBundle;  
public class Sample extends ListResourceBundle {  
    public Object[][] getContents() {  
        return contents;  
}
    static final Object[][] contents = {
        { "myfruit.fruit1", "Mango" },
        { "myfruit.fruit2", "Orange" },
    };  
}
index.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>  

<fmt:message basename="myPackage.Sample" var="fruits" />  
	<fmt:message key="myfruit.fruit1" bundle="${fruits}" /><br />  
	<fmt:message key="myfruit.fruit2" bundle="${fruits}" /><br />
Output :
Mango
Orange

Store Localized Message to Variable in JSTL

<fmt:setBundle basename="myPackage.Sample" var="fruits" />  
	<fmt:message key="myfruit.fruit1" bundle="${fruits}" var="name1" />${name1}<br />  
	<fmt:message key="myfruit.fruit2" bundle="${fruits}" var="name2" />${name2}<br />
Mango
Orange