<fmt:setLocale value='ru'/>
<fmt:setBundle basename='Messages'/>
fmt:message без использования фреймворков
я не использую Struts, Spring или что-то другое.
пытаюсь использовать тег fmt:message
на jsp странице есть <%@ include file="taglibs.jsp"%>, в нем
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
в папке util есть два файлика Messages_ru.properties и Messages_en.properties
пробовала писать в jsp, где используется fmt, так:
Код:
или окружила использование fmt:message
Код:
<fmt:bundle basename="util.Messages_ru">
пробовала написать в web.xml
Код:
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>Messages_ru</param-value>
</context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>Messages_ru</param-value>
</context-param>
в lib есть servlet-api.jar и standart-1.1.2.jar и есть папка javax, где jsp-api, servlet-api, jstl.
я неправильно прописываю путь до Messages? или куда кидать эту папку util в webapps у tomcat? так как -
ошибка постоянно такая:
Код:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
java.lang.Class.getDeclaredMethods(Class.java:1791)
java.beans.Introspector$1.run(Introspector.java:1272)
java.security.AccessController.doPrivileged(Native Method)
java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)
java.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)
java.beans.Introspector.getBeanInfo(Introspector.java:387)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
java.beans.Introspector.getBeanInfo(Introspector.java:220)
java.beans.Introspector.<init>(Introspector.java:368)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3820)
org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2112)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1601)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:638)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.fmt.LocalizationContext
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
java.lang.Class.getDeclaredMethods(Class.java:1791)
java.beans.Introspector$1.run(Introspector.java:1272)
java.security.AccessController.doPrivileged(Native Method)
java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)
java.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)
java.beans.Introspector.getBeanInfo(Introspector.java:387)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
java.beans.Introspector.getBeanInfo(Introspector.java:220)
java.beans.Introspector.<init>(Introspector.java:368)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3820)
org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2112)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1601)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:638)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/fmt/LocalizationContext
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
java.lang.Class.getDeclaredMethods(Class.java:1791)
java.beans.Introspector$1.run(Introspector.java:1272)
java.security.AccessController.doPrivileged(Native Method)
java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)
java.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)
java.beans.Introspector.getBeanInfo(Introspector.java:387)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
java.beans.Introspector.getBeanInfo(Introspector.java:220)
java.beans.Introspector.<init>(Introspector.java:368)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3820)
org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2112)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1601)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:638)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.fmt.LocalizationContext
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
java.lang.Class.getDeclaredMethods(Class.java:1791)
java.beans.Introspector$1.run(Introspector.java:1272)
java.security.AccessController.doPrivileged(Native Method)
java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1270)
java.beans.Introspector.getTargetMethodInfo(Introspector.java:1136)
java.beans.Introspector.getBeanInfo(Introspector.java:387)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
java.beans.Introspector.getBeanInfo(Introspector.java:220)
java.beans.Introspector.<init>(Introspector.java:368)
java.beans.Introspector.getBeanInfo(Introspector.java:159)
org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3820)
org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2112)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1601)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1512)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:638)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
но fmt:messages не работает. видимо теперь не может найти мой Messages_ru.properties :(
в общем, папка util должна находиться в classes
теперь на каждой странице я пишу
<fmt:setLocale value='ru'/>
<fmt:setBundle basename='util.Messages'/>
если кто-то подскажет другой путь - буду благодарна