When I learned from Chapter 12 "struts2 authoritative guide>, I encountered the problem of integrating freemarker.
If struts labels are used, an error is reported.
<#assign s =JspTaglibs["/WEB-INF/struts-tags.tld"]>
If the freemarker label is used, an error is reported.
Classnotfound: org. Apache. stuts. Views. jsp. UI. autocompletertag., this class cannot be found.
After reading the foreign website, I found that:
I was using struts-tags.tld file from earlier version of Struts. And that is why it was referencing the autocompletertag class.
ClassNotFoundException: org.apache.struts2.views.jsp.ui.AutocompleterTag
So to solve this problem, just un-jar the struts2.2.3-core. jar file, and get the struts-tags.tld file from META-INF folder, and put it in your resources (WEB-INF/struts-tags.tld ).
That is to say, the TLD file I used is wrong with the version of the struts-core.jar. Then I extracted my TLD from the jar file and replaced the old version.
Web. xml
<? XML version = "1.0" encoding = "UTF-8"?> <Web-app version = "2.5" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <! -- Configure the struts filter, define the filter class, and the type of the intercepted request --> <filter-Name> freemkstruts </filter-Name> <filter-class> Org. apache. struts2.dispatcher. filterdispatcher </filter-class> </filter> <filter-mapping> <filter-Name> freemkstruts </filter-Name> <URL-pattern>/* </url-Pattern> </filter-mapping> <! -- Use the struts2 tag in freemarker, to enable freemarker to use JSP labels, you must configure a new servlet --> <servlet-Name> jspsuppservlet servlet </servlet-Name> <servlet-class> Org. apache. struts2.views. jspsuppservlet servlet </servlet-class> <load-on-startup> 1 </load-on-startup> </servlet> <welcome-file-List> <welcome-File> Login. JSP </welcome-File> </welcome-file-List> </Web-app>
Login. FTL
<# Assign S = jsptaglibs ["/WEB-INF/struts-tags.tld"]> <HTML>