我正在尝试使用基于如何国际化Java Web应用程序的 JSTL 1.2来使我的网站国际化?.这是JSP文件的开头:
<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="com.bundle.test" />
<html lang="${language}">
Run Code Online (Sandbox Code Playgroud)
这是test.properties文件:
login.label.username = Username
login.label.password = Password
login.button.submit = Sign in
login.label.direction = rlt
Run Code Online (Sandbox Code Playgroud)
在身体中,我包括这些线:
<label for="username"><fmt:message key="login.label.username" /></label>
Run Code Online (Sandbox Code Playgroud)
但是当我在浏览器中打开JSP页面时,它输出如下:
??? ??? login.label.username
我希望它输出值"Username".
这是怎么造成的,我该如何解决?
如果我有一个void方法,在某些条件下终止它的一种方法是使用关键字"return",类似这样
public void test() {
if (condition()) {
return;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个返回字符串的方法怎么办?
public String test() {
if (condition()) {
//what to do here to terminate from the method, and i do not want to use the null or "" return
}
}
Run Code Online (Sandbox Code Playgroud)