- This topic has 5 replies, 2 voices, and was last updated 18 years, 1 month ago by Riyad Kalla.
-
AuthorPosts
-
cpyong27MemberHi,
My web.xml looks like below, but I am getting an error at the line where <taglib> is. Anyone knows what has gone wrong? I really have fmt.tld in the /WEB-INF/tld directory.<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” version=”2.4″
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping><taglib>
<taglib-uri>/WEB-INF/fmt.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib></web-app>
Riyad KallaMemberOne of the changes with the Web 2.4 specification is tha tyou now need to wrap your taglib tags inside of <jsp-config> tags. Give that a try.
cpyong27MemberThanks for your prompt reply. The error is now gone, but I still cannot get it to load the keys defined in ApplicationResource.properties though I have defined <message-resources parameter=”com.cmr.struts.ApplicationResources” /> in struts-config.xml. For example, my user login page which consists of simply 2 labels (for stating name & password), 2 text boxes (for name & passowrd input) and a login button, does not display the correct text defined in ApplicationResources.properties. This is the code of my user login jsp:
<%@ page language=”java”%>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean” prefix=”bean”%>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-html” prefix=”html”%>
<%@ taglib uri=”/WEB-INF/fmt.tld” prefix=”fmt”%><html>
<head>
<fmt:setBundle basename=”ApplicationResources” />
<title>JSP for UserLoginForm form</title>
</head>
<body>
<html:errors property=”login”/>
<html:form action=”/userLogin” focus=”userName”>
<table align=”center”>
<tr align=”center”>
<td><H1><fmt:message key=”login.message” /></H1></td>
</tr>
<tr align=”center”>
<td>
<table align=”center”>
<tr>
<td align=”right”>
<fmt:message key=”login.username”/>
</td>
<td align=”left”>
<html:text property=”userName” size=”15″ maxlength=”15″/>
<html:errors property=”userName”/>
</td>
</tr>
<tr>
<td align=”right”>
<fmt:message key=”login.password”/>
</td>
<td align=”left”>
<html:text property=”password” size=”15″ maxlength=”15″/>
<html:errors property=”password”/>
</td>
</tr>
<tr>
<td colspan=”2″ align=”center”>
<html:submit>
<fmt:message key=”login.button.signon”/>
</html:submit>
</td>
</tr>
</table>
</td>
</tr>
</table></html:form>
</body>
</html>and this is the content of the ApplicationResources.properties:
# Resources for parameter ‘com.cmr.struts.ApplicationResources’
# Project P/CMROnline#login page text
login.message=Welcome to CMR Online
login.username=User ID:
login.password=Password:
login.button.sigon= Log In Here!———————————————
I hope u could help me again. Appreciate that.
Riyad KallaMemberYour basename is wrong, it has to be the full package: com.cmr.struts.ApplicationResources
cpyong27MemberHi Riyad,
Thanks again for your prompt reply. It works now. The error was due to my lack of understanding of “basename”. You are really my hero!!!
Thank you very much!!!Regards,
Jacob
Riyad KallaMemberI’m glad it’s working, it’s always the little things that bog us down isn’t it?
-
AuthorPosts