1:xxxxxxxxxx
2:request.getParameter("target");在第一行写一句什么代码,第二行能够得到数据。别告诉我request.setAttribute( "target ", "target ");这样得不到数据。
2:request.getParameter("target");在第一行写一句什么代码,第二行能够得到数据。别告诉我request.setAttribute( "target ", "target ");这样得不到数据。
解决方案 »
- struts2疑似让<welcome-file>失效的奇怪问题
- include指令是不是只能支持html的页面
- 正在学习孙卫琴的tomcat和java web,bookstore的version0出现乱码
- 在页面中的图片怎么样保存到数据库
- 谁帮解释一下struts2里struts.xml的一些配置信息
- 关于用struts的tiles的刷新问题?
- 如何判断一个byte是否是中文字符的一半
- 请用过FlaX V3.00 ( Flash 文字特效的工具)的大侠进来看看,谢谢!
- 求教:jsp的传参语名书写问题?
- 为什么我的文件保存成这种乱码?
- tomcat 内存溢出如何处理??
- HTTP ERROR: 200
这句代码是获取请求参数,参数名为target的值。需要用超链接传参如:<a href='http://localhost:8080/demo/demo.jsp?target=123';当点这个超链接时,在demo.jsp里面用
String target = request.getParameter("target");
就能得到target的值。
或者用表单提交的方式。有表单元素的name属性为target.提交给后台就能用这种方式去取值.
直接在前面加代码是没用的。必须用请求的方式。才能传值。
如这个:
http://www.325204.com/promotion.php?uid=454187
你就可以这样拿
String uid = request.getParameter("uid");
uid=454187
这个那值要这样拿request.getAttribute("target");
对于 parameter 可以是前个页面的 表单 input 标签的元素,也可以说是页面地址栏后面加(?id=1)
id=request.getParameter("id");
也可以是地址栏路径后面加 (?id=1) 获取这个id就是用getParameterhttp://localhost:8080/Project/index.jsp?id=1;
id=request.getParameter("id");
2:request.getParameter("target");在第一行写一句什么代码,第二行能够得到数据。别告诉我request.setAttribute( "target ", "target ");这样得不到数据。- -你第二行的是getParameter,第一行setAttribute???肯定得不到撒....
Parameter是参数,无法设置只有从前一个页面或者地址栏传入...
request.getParameter(参数)上一个页面中表单中数据
隐藏域中的也能获得。注意同一页面中的参数别重复了。
Field field=org.apache.catalina.connector.RequestFacade.class.getDeclaredField("request");
field.setAccessible(true);
org.apache.catalina.connector.Request real=(org.apache.catalina.connector.Request)field.get(request);
real.getCoyoteRequest().getParameters().addParameterValues("test",new String[]{"aaakkkkk"});这样就可以获取到相应的值了
你要存数据,用setAttribute,读就用getAttribute;
我是从来没有想过要设一个参数进去,然后要用getParameter来得到;