简体   繁体   中英

Applying bootstrap styles to Struts 1.x html tags

I am working on some legacy Struts 1.x applications that use Struts html tags instead of standard html tags. I am trying to modernize the UI without making functional changes.

For example: The input field is <html:text property="someProperty" styleClass="someCssStyle">

instead of <input type="text" class="someCssStyle">

If I change, <html:text> to <input type="text"> the property binding breaks ie the value in input field is not passed to the code.

If I try to apply bootstrap styles to <html:text> , it does not work.

How can I apply Bootstrap styles to legacy struts html tags?

You have add the style(s) to the styleClass attribute.

For example:

<html:text property="propName" name="formName" styleClass="form-control"></html:text>

or

<html:submit styleClass="btn btn-link">submit</html:submit>

Here is a very basic sample app on GitHub that shows this working: https://github.com/lviviani/sample-struts-bootstrap

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM