INDEX.JSP~~
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
  <!--   <form action="<%=request.getContextPath()%>/NewsServlet" method="post">-->
      <form action="MyJsp.jsp" method="post">
<input type="hidden" name="Action" value="EditNews" />
<input type="hidden" name="EditNewsID" value="" />
<label>
xxx:
<input type="text" name="Title" value="" />//为什么传不到SERVLET和JSP中,
</label>
<p>
&nbsp;
</p>
<p>
xxx:
<textarea name="Content" rows="10" class="td_index_globle"></textarea>
<input type="submit" name="submit" value="提交" />
</p>
</form>
  </body>
</html>SERVLET~~
import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class NewsServlet extends HttpServlet {
public NewsServlet() {
super();
}
public void destroy() {
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
String doWhat = request.getParameter("Action");
if(doWhat!=null){
if("EditNews".equals(doWhat)){
String Title = request.getParameter("Title");
String Content = request.getParameter("Content");

System.out.println(request.getParameter("==============="+ Title));
System.out.println(request.getParameter("==============="+ Content));
}
}
} public void init() throws ServletException {

}
}MyJsp.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
   <%
   String Title = request.getParameter("Title");
String Content = request.getParameter("Content");

System.out.println(request.getParameter("==============="+ Title));
System.out.println(request.getParameter("==============="+ Content));
    %>
  </body>
</html>
servlet和JSP中都拿不到值,郁闷,哪出错了呢?

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【javabird1986】截止到2008-07-18 23:08:06的历史汇总数据(不包括此帖):
    发帖的总数量:38                       发帖的总分数:901                      每贴平均分数:23                       
    回帖的总数量:125                      得分贴总数量:21                       回帖的得分率:16%                      
    结贴的总数量:35                       结贴的总分数:746                      
    无满意结贴数:1                        无满意结贴分:20                       
    未结的帖子数:3                        未结的总分数:155                      
    结贴的百分比:92.11 %               结分的百分比:82.80 %                  
    无满意结贴率:2.86  %               无满意结分率:2.68  %                  
    值得尊敬
      

  2.   

    拿不到值?是说title和content是null吗
      

  3.   

    是出现异常了,还是打印出null或空字符串?
      

  4.   

     <base href="<%=basePath%>">把这句去掉
      

  5.   

    System.out.println(Title);                
    System.out.println(Content);
    这样写
      

  6.   

    首先要确认,在INDEX.JSP里提交Form时,请求能否到达MyJsp.jsp或SERVLET