Problems with struts2 integration freemarker (autocompletertag)

Source: Internet
Author: User
Tags tld

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> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.