Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6019705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:27:36+00:00 2026-05-23T03:27:36+00:00

When you use a <struts:text name=…/> Struts 2 Text jsp tag, you get a

  • 0

When you use a <struts:text name="..."/> Struts 2 Text jsp tag, you get a text from a .properties file in the page.

For example, if the .properties-file contains

foo.bar = This is the text.

The jsp tag <struts:text name="foo.bar"/> will output

This is the text.

Now i would like for all instances of <struts:text name="..."> in the webapp to also output the name attribute inside an HTML comment, like so:

<!-- foo.bar -->This is the text.

I tried creating my own jsp tag file (to use instead of <struts:text>) that contained

<%@attribute name="name" required="true"%>

<!-- ${name} --><struts:text name="${name}"/>

but it doesn’t work because <rtexprvalue> is set to false for the name attribute of the struts:text tag.

Any ideas how this can be accomplished?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:27:37+00:00Added an answer on May 23, 2026 at 3:27 am
    # PROPERTIES
    copyright.year=2011
    

    (B) : Override default theme (is acceptable)

    label.ftl

    Add following code <!-- ${parameters.name?html} -->

    <!-- ${parameters.name?html} -->
    
    <label<#rt/>
    ...
    </label>
    

    .jsp

    <s:label key="copyright.year" />
    

    HTML output :

    2011
    

    HTML source :

    <!-- copyright.year -->
    <label id="form_name_copyright_year">2011</label>
    

    OR (not recommend)

    label.ftl with only 4 lines of code

    <#if parameters.nameValue??>
    <!-- ${parameters.name?html} --><#rt/>
    <@s.property value="parameters.nameValue"/><#t/>
    </#if>
    

    HTML source :

    <!-- copyright.year -->2011
    

      (A)  

    /**
     * Overridden/replacement for {@link ActionSupport}.
     */
    public class MyActionSupport extends ActionSupport {
    
        public String text(String fieldName) {
            return "<!-- " + fieldName + " --> " + getText(fieldName);
        }
    }
    


    public class MyAction extends MyActionSupport {
    
    }
    

    .jsp

    <s:property value="text('copyright.year')" escapeHtml="false" />
    

    HTML output :

    2011
    

    HTML source :

    <!-- copyright.year --> 2011
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose name contains non-ascii characters, when I use <s:property value=name /> , Struts automatically
I use struts-html to generate forms fields. For example: <%@ taglib prefix=html uri=/WEB-INF/taglibs/struts-html.tld %>
Often times, when I use struts 2 tags, the loading of a page will
I'm using struts 2 <s:form> tag. Now I want use design prepared by our
I use GAE and struts. When I input htpp://localhost:8888 , it will autoload index.jsp.
My project changed version of struts from struts-2.1.8.1 to struts-2.2.1. We don't use suffix
I'm trying to use Struts validation to check various fields entered by users. If
I want to learn how to use Struts 2 and I created a simple
Setup : I have a Struts web application where I use displaytag elements to
I am using Struts 2.1.8.1 . I want to use tags, supplied by struts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.