request.setAttribute("abc",v);response.sendRedirect("http://cg:7001/clubsite/index.jsp");
不能这样传参数,传不过去。
不能这样传参数,传不过去。
解决方案 »
- jsp如何实现文本域内容不能被全选
- 请教大哥哥们 struts2 jsp页面取值,需要取的值是一个List对象的中的一个List对象中的值
- 散分的问题。100分,分数太多了
- 请问eclipse中加如tomcatplus之后为何在eclipse配置中还是找不到tomcat相关项
- 长期以来有个问题一直没搞清楚,大家有空帮我解释下,先谢过了
- 如何使Javascript传值给JSP,然后提交页面,执行新的JSP请求(程序)?请给出示例,谢谢!
- 如何将javascript变量传到jsp中
- tomcat3.3以上版本中web.xml的问题
- 谁有JPad Pro4.3注册码?
- install后war包和jar包错怎么解决呢?求大神们帮帮忙
- 关于javascript里用document对象,有点糊涂,高手帮忙看一下。
- jsp中怎样连接ORACLE SQL等数据库?
RequestDispatcher dispatcher = null;
request.setAttribute("abc",v);
dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class test extends HttpServlet {
protected ServletConfig servletConfig;
public void init(ServletConfig config) {
this.servletConfig = config;
}public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
Vector v=new Vector();
v.add("aa");
v.add("bb");
request.setAttribute("abc",v);
servletConfig.getServletContext().getRequestDispatcher("http://cg:7001/clubsite/index.jsp").forward(request,response);
}
}
把你的response.sendRedirect("http://cg:7001/clubsite/index.jsp");改为:this.getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request,response)等你结果
用了zhangbin_zhang(cat) 的程序
页面返回:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
---------------
我要100分给你解决方案,
把你的response.sendRedirect("http://cg:7001/clubsite/index.jsp");改为:this.getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request,response)
---------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class test extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
Vector v=new Vector();
v.add("aa");
v.add("bb");
request.setAttribute("abc",v);
this.getServletConfig().getServletContext().getRequestDispatcher("/test.jsp").forward(request,response);
//response.sendRedirect("/sohosystem/test.jsp");
}
}
---------------
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"
%>
<%Vector a=(Vector)request.getAttribute("abc");
if(request.getAttribute("abc")!=null){
out.println("OK");
}
if(a==null){
out.println("<p>a is null");
}
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
</body>
</html>
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class test extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
Vector v=new Vector();
v.add("aa");
v.add("bb");
request.setAttribute("abc",v);
this.getServletConfig().getServletContext().getRequestDispatcher("http://localhost:7001/clubsite/clubsite/publish.jsp").forward(request,response);
} }