java 如何在jsp中从html textarea line String java给出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4411494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:15:00  来源:igfitidea点击:

how give from html textarea line String java in jsp

javahtmljspservlets

提问by ferz

Is such html code page jsp?

这样的html代码页是jsp吗?

<form action="">
<div align="center"><textarea name="" cols="50" rows="4">welcome to my program</textarea></div>
</form>

if write in this textarea line. How the line translate in object String in servlet?

如果在此 textarea 行中写入。该行如何在 servlet 中的对象字符串中转换?

I'm know such the way.

我知道这样。

  <form action="perform_action.jsp" method="post">
      <input type="submit" value="OK">
  </form>

perform_action.jsp:

perform_action.jsp:

if ( <all_ок> ) { 
    Sample.task(); 
}

may way do on the one page jsp? sorry for bad english.

有办法在一页上做jsp吗?抱歉英语不好。

回答by BalusC

Let the form action point to the servlet URL as definied in <url-pattern>in web.xmland give the input elements a name.

让表单操作指向 in<url-pattern>中定义的 servlet URL ,web.xml并为输入元素命名。

<form action="servleturl" method="post">
    <textarea name="text"></textarea>
    <input type="submit">
</form>

The submitted content will be available in doPost()method of servlet as request parameter where you use the name of the input element as parameter name.

提交的内容将在doPost()servlet 的方法中可用作为请求参数,其中您使用输入元素的名称作为参数名称。

String text = request.getParameter("text");

See also:

也可以看看: