将 TextField 值(参数)发送到 servlet
我有 3 个文本字段(Vaadin)(DBName、DBUserName、DBPassword)我想将输入的文本从 portlet 发送到 servlet,这就是我到目前为止所得到的:
Portlet 部分:
TextField DBName;
TextField DBUserName;
TextField DBPassword;
DBName = new TextField("Enter DB Name");
DBName.setColumns(20);
DBUserName = new TextField("Enter UserName");
DBUserName.setColumns(20);
DBPassword = new TextField("Enter Password");
DBPassword.setColumns(20);
//Button
if(event.getSource()== Connect){
Resource newPictureResource = new ExternalResource("http://localhost:8888/portlet/picture?UserName="+DBUserName.getValue()+"&DBPassword="+DBPassword.getValue()+"&DBName="+DBName.getValue());
picture.setSource(newPictureResource);
editContent.addComponent(picture);
}
Servlet 部分:
这里没有想法,是考虑
String UserName = request.getParameter("DBUserName");
String Password = request.getParameter("DBPassword");
String DataBase = request.getParameter("DBName");
我想获取已输入到文本字段的值, 有什么想法吗?
i have 3 TextFields (Vaadin) ( DBName, DBUserName, DBPassword) i want to send the typed in text from a portlet to a servlet , this is what i've got so far :
Portlet part:
TextField DBName;
TextField DBUserName;
TextField DBPassword;
DBName = new TextField("Enter DB Name");
DBName.setColumns(20);
DBUserName = new TextField("Enter UserName");
DBUserName.setColumns(20);
DBPassword = new TextField("Enter Password");
DBPassword.setColumns(20);
//Button
if(event.getSource()== Connect){
Resource newPictureResource = new ExternalResource("http://localhost:8888/portlet/picture?UserName="+DBUserName.getValue()+"&DBPassword="+DBPassword.getValue()+"&DBName="+DBName.getValue());
picture.setSource(newPictureResource);
editContent.addComponent(picture);
}
Servlet part :
no ideas here , was thinkig about
String UserName = request.getParameter("DBUserName");
String Password = request.getParameter("DBPassword");
String DataBase = request.getParameter("DBName");
I want to get the Values that has been entered to the text field,
any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码看起来快完成了。我只编辑了一点(我不确定你的实际问题是什么)。您可以简单地使用 java 的内置支持发布数据。您可以在 vaadin 书籍中阅读有关查询字符串的更多信息。
Your code almost looks finished. I only edited it a little bit (I wasn't sure what your actual problem was). You could simply use java's built in support for posting data. You can read more about querystrings in the vaadin book.