spring mvc 表单 textarea 初始内容 [英] spring mvc form textarea initial contents

查看:31
本文介绍了spring mvc 表单 textarea 初始内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将初始文本放入 Spring 表单文本区域?TLD 拒绝 form:textarea 中的 PCData 内容.此表单的重点是要求用户编辑/更正某些文本,因此文本必须首先进入表单.JSP 页面正在从模型中拉取文本,并希望将其放入 textarea.

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.

推荐答案

您可以使用 Javascript 设置初始值.您可以使用标签来控制何时需要在文本框中设置消息,以便呈现或不呈现脚本代码.

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.

这篇关于spring mvc 表单 textarea 初始内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆