실제 예)
2008-05-12 19:53:15 [ERROR](StandardWrapperValve.java:253) Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: In <parseNumber>, a parse locale can not be established
at org.apache.taglibs.standard.tag.common.fmt.ParseNumberSupport.doEndTag(ParseNumberSupport.java:134)
해답 )
I was able to solve this problem.
I had to set
<fmt:setLocale value="en-US"/>
and set the parseLocale attribute of fmt:parseNumber
to "en-US"
I was only getting this error in Tomcat's
localhost2006-09-21.log when a User Agent from Germany
was accessing the page which had fmt:parseNumber on
it.
The JSTL spec says that if a locale is not specified
then it defaults to the browser's locale.
That must have caused this error.
--- Rashmi Rubdi <[EMAIL PROTECTED]> wrote:
> I couldn't find any information on this error:
>
> javax.servlet.jsp.JspException:
> In <parseNumber>, a parse locale can not be
> established
>
> I only see this error in the server logs and it does
> not prevent the JSP page from executing and
> displaying
> itself.
>
> I think this error was caused by this line of code
> in
> my JSP:
>
> <fmt:parseNumber var="quotient"
> value="${item_position
> div 10}" type="number" integerOnly="true" />
>
> In the above code i'm trying to divide item_position
> by 10 and trying to get only the integer portion of
> the result. (Not performing any i8n)
>
> In short, I'm trying to integer truncate the
> quotient.
>
>
> Am I supposed to set the locale before using
> fmt:parseNumber?
>
> Although this page displays correctly, I'm having
> problems while crawling/spidering the page and wish
> to
> eliminate all errors to ensure that the page is
> crawled properly.
>
> Please help.
>
> -Rashmi
at Re: Need info on: JspException: In <parseNumber>, a parse locale can not be established
해석하자면. jsp 페이지 내에 로케일이 정보가 없을 경우(명시적 셋팅이 없는 경우.)
사용자의 브라우저 디폴트 로케일로 parseNumber 태그가 실행 되기 때문에 생기는 문제.
결론은. 로케일 정보가 없어서 생기는 상황.
ParseNumberSupport.java:134 라인 소스
/*
* Set up parsing locale: Use locale specified via the 'parseLocale'
* attribute (if present), or else determine page's locale.
*/
Locale loc = parseLocale;
if (loc == null)
loc = SetLocaleSupport.getFormattingLocale(
pageContext,
this,
false,
NumberFormat.getAvailableLocales());
if (loc == null) {
throw new JspException(
Resources.getMessage("PARSE_NUMBER_NO_PARSE_LOCALE"));
}
방법은 페이지 내에 명시적으로 로케일을 적어 주고.
parseNumber 태그의 어트리뷰트인 parseLocale 도 명시적으로 선언 해야 한다.
일반적인 상황에는 현상이 발생 하지 않고. 어떠한 다른 환경(OS, browser) 에서 발생 되는 것으로
생각 된다. (일반적인 jsp 페이지 내에서는 이러한 로케일 설정이 따로 없기 때문에.)
아무튼. 무엇이든 '명시적'인 것이 제일 좋은 해결책인것 같다.
반응형
'emotional developer > detect-Java' 카테고리의 다른 글
DBCP defaultTransactionIsolation (0) | 2008.05.19 |
---|---|
Eclipse 내, tomcat work디렉토리 위치. (0) | 2007.12.03 |
How ConcurrentHashMap offers higher concurrency without compromising thread safety (2) | 2007.11.26 |