i am new to Struts.i have tried an sample struts1.x application.when i run it ,it gives an error
The absolute uri: http://struts.apache.org/tags-html cannot be resolved in either web.xml or the jar files deployed with this application" my jsp page has '<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>'
web page:
<html>
<body>
<center>
<html:errors/>
<html:form action="login">
<bean:message key="label.uname"/>
:
<html:text property="uname"/>
<br>
<bean:message key="label.pwd"/>
:
<html:text property="pwd"/>
<br>
<html:submit value="LOGIN"/>
</html:form>
</center>
</body>
</html>
web.xml:
<web-app>
<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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
Try this
Include the below jar
as dependency [in WEB-INF/lib
]
struts-taglib.jar [any version, eg: struts-taglib-1.3.10.jar]
In JSP page :
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
How this works: The tag library descriptor [tld] information are defined inside the “struts-taglib.jar\META-INF\tld”
You can have a look at the answer mentioned in this SO post. I have a running example there No getter method for property... error
So either you can have the jar file as dependency or add the tag library descriptors inside your WEB-INF, and configure in web.xml
web.xml
<taglib>
<taglib-uri>
http://struts.apache.org/tags-bean
</taglib-uri>
<taglib-location>
/WEB-INF/struts-bean.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>
http://struts.apache.org/tags-html
</taglib-uri>
<taglib-location>
/WEB-INF/struts-html.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>
http://struts.apache.org/tags-logic
</taglib-uri>
<taglib-location>
/WEB-INF/struts-logic.tld
</taglib-location>
</taglib>
There is a mapping between what you configure here and the taglib
you define in jsp page.
The @taglib uri
in the jsp page have to match with <taglib-uri>
defined in web.xml
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>