java 将值从 jsp 传递到 servlet
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10268415/
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
passing value from jsp to servlet
提问by Lucy
I need your help in this particular issue I want to pass the value of a hidden input type in a .jsp program to a servlet program
我需要你在这个特定问题上的帮助我想将 .jsp 程序中隐藏输入类型的值传递给 servlet 程序
what I am doing is basically this
我正在做的基本上是这个
<input type="hidden" name="articleId" id="articleId" value=" <%request.getParameter("articleId");%>"/>
and from the servlet I am getting the value
并从 servlet 我得到了价值
String articleId = request.getParameter("message");
PrintWriter out = response.getWriter();
out.println(articleId);
It doesn't print any think . the jsp form method is post and the servlet method is doPost
它不打印任何 think 。jsp表单方法是post,servlet方法是doPost
any Ideas why it doesn't pass the parameter?
为什么它不传递参数的任何想法?
回答by Nurlan
1: change your input value(you forget <%=):
1:更改您的输入值(您忘记了 <% =):
<input type="hidden" name="articleId" id="articleId" value="<%=request.getParameter("articleId");%>" />
2: change your argument in getParamater:
2:在 getParamater 中更改您的参数:
String articleId = request.getParameter("articleId");
PrintWriter out = response.getWriter();
out.println(articleId);
回答by Pau Kiat Wee
You used wrong parameter, should do as following:
您使用了错误的参数,应执行以下操作:
String articleId = request.getParameter("articleId");
PrintWriter out = response.getWriter();
out.println(articleId);