HTML5 placeholder inside Struts html:text tag

北慕城南 提交于 2019-12-10 14:40:27

问题


I'm using Struts 1.3.10 in a web application, and I want my textfields to have a placeholder. Unfortunately, the current Struts taglib doesn't recognize this attribute, and I would like to avoid using javascript for this if possible. Do you know any solution for this?


回答1:


Struts 1 is dead. It hasn't had a release since 2008. I would really think about migrating to a more modern framework.

If you're stuck with Struts 1, you could

  • edit the sources yourself, and add a placeholder attribute to the tag.
  • avoid using the tag, and go back to basic HTML + JSTL + EL :

    <input type="text" name="foo" value="<c:out value='${myForm.foo}' />" 
           placeholder="Enter foo here" />
    



回答2:


In case this might be helpful to others:

If you have a JavaBean (with getters and setters) you could use basic html and the bean:write struts tag.

<input type="text" name="foo" placeholder="Enter foo here"value="<bean:write name="myFormBean" property="foo" />"> 


来源:https://stackoverflow.com/questions/9337621/html5-placeholder-inside-struts-htmltext-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!