[英]Multi Line Text Area using htmlunit
Requirement: I have a multi line textarea in the webpage with some default value , i need to change that values and submit the form. 要求:我在网页中有一个多行文本区域,并带有一些默认值,我需要更改该值并提交表单。 The text area defnition is as below.
文本区域定义如下。
<textarea id="editorarea" name="_editedtext"
class="editor"
onkeyup="getSuggestions(this.id)"
onclick="setCursorPos(this.id)"
onchange="setCursorPos(this.id)"
rows="20" cols="80">! Lorem ipsum" text is derived
from sections 1.10.32–3 of Cicero's De
finibus bonorum et malorum (On the Ends of Goods
Problem: When I set the text for the textarea from a string it becomes like below : 问题:当我从字符串设置textarea的文本时,它如下所示:
<textarea id="editorarea" name="_editedtext"
class="editor"
onkeyup="getSuggestions(this.id)"
onclick="setCursorPos(this.id)"
onchange="setCursorPos(this.id)"
rows="20" cols="80">Lorem ipsum" text is derived<br>from sections 1.10.32–3 of Cicero's De <br>| LPAR Name If Remote:| N/A1<br>\\ <br>! Endpoints<br>finibus bonorum et malorum (On the Ends of Goods'<br>
so the the content becomes a single line, the line break is not getting recogonised, i tried "\\n" , " 因此内容变成了一行,换行符没有重新显示,我尝试了“ \\ n”,“
" both didn't work. ”“两个都没有用。
I am having my input in a arraylist and convert them to a single string as below: 我将输入输入到arraylist中,并将它们转换为单个字符串,如下所示:
public static void createString(){
StringBuilder sb = new StringBuilder();
for(String s : finalModifiedList){
sb.append(s);
sb.append("<br>");
}
finalString =sb.toString();
and setting the textarea content as below 并设置textarea内容如下
HtmlTextArea erfTextarea = textAreaForm.getTextAreaByName("_editedtext");
erfTextarea.setText(content);
TextArea Charset is : UTF-8 TextArea字符集为:UTF-8
Please let me know how to enter the multi-line text using htmlunit 请让我知道如何使用htmlunit输入多行文本
replace sb.append("<br>");
替换
sb.append("<br>");
with sb.append("\\n");
用
sb.append("\\n");
in createString() 在createString()中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.