spring mvc form textarea initial contents

江枫思渺然 提交于 2019-12-12 01:35:06

问题


How do I put initial text into a Spring form textarea? The TLD rejects PCData content inside form:textarea. The point of this form is to ask a user to edit/correct some text, so the text has to get into the form in the first place. The JSP page is pulling the text from the model and wants to put it into the textarea.


回答1:


You could set the initial value with Javascript. You could use tags to control when you need to set the message in the textbox so the script code will be rendered or not.

Another way it could be setting the text value in the corresponding property of the model attribute, though I think it is more clean the other solution because this message is just a help to the user, so I think it should be done in the view.



来源:https://stackoverflow.com/questions/3167859/spring-mvc-form-textarea-initial-contents

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