<a href="newsdetail.do"?id=<bean:write name="n" property="id"/>> <bean:write name="n" property="title"/>
 </a>
从Mysql中查出来的title,点击新闻标题,跳转到新闻的具体内容(content),struts根据.do跳转不是很清楚,我做的点击新闻标题后显示空白页.IE栏 出现的是http://localhost:8080/hanz/newsdetail.do。

解决方案 »

  1.   

    这样试试<a href='newsdetail.do?id= <bean:write name="n" property="id"/>'>
      

  2.   

    struts1 中在 web.xml 是这样配置的:
     
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>3</param-value>
        </init-param>
        <init-param>
          <param-name>detail</param-name>
          <param-value>3</param-value>
        </init-param>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>就是说所以以 .do 结尾的 action 都提交给struts处理.至于: http://localhost:8080/hanz/newsdetail.do 这个url是 struts 自动处理过的连接.
      

  3.   

    这样试试 <a href='newsdetail.do?id= <bean:write name="n" property="id"/>'> 
    你的ie栏应该是http://localhost:8080/hanz/newsdetail.do?id=...。 
      

  4.   

    从Mysql中查出来的title,点击新闻标题,跳转到新闻的具体内容(content),struts根据.do跳转不是很清楚,我做的点击新闻标题后显示空白页.IE栏 出现的是http://localhost:8080/hanz/newsdetail.do。 对于为什么是.do 上面各位已经说得很清楚,注意到LZ说的意思:是不是想说,为什么你的空白页的地址栏的地址是:http://localhost:8080/hanz/newsdetail.do,对吗?先说一下转到其他页面有两种方式(第三种方式是直接在地址栏输网址)就是重定向和转发。重定义后,地址栏地址变为重定义后访问的地址。而转发时地址栏还是原地址,但是内容是转发后指向的内容。所以地址是那个的原因是,你使用了转发
      

  5.   

    <a href="newsdetail.do"?id= <bean:write name="n" property="id"/>> 
    你的id应该放入href="newsdetail.do?id=..."之中吧,你怎么写外边去了
    修改成<a href="newsdetail.do?id= <bean:write name="n" property="id"/>"> 
      

  6.   

    我想下载j2ee api doc  谁有啊
      

  7.   

    首先谢谢这位仁兄,根据您说的该了之后IE栏出现的是http://localhost:8080/hanz/newsdetail.do?id=6
    但出现错误org.apache.jasper.JasperException: /news.jsp(36,18) Attribute propeXrty invalid for tag write according to TLD
    我要的效果就是点击新闻标题,跳转到news.jsp,news.jsp显示该标题的内容,内容从数据库查出
      

  8.   

    把你news.jsp页面代码贴出来看看。.获取到ID 了没有.?
    <a href="newsdetail.do?id= <bean:write name="n" property="id"/>"> 
      

  9.   

    news.jsp
    <%@ page language="java"  import="java.util.*"  pageEncoding="utf-8" import="com.web.hanz.*"%>
    <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%> 
    <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html"%>
    <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic"%>  
    <%
      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>北京汉众信息科技有限责任公司</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>
       <%newsForm f=(newsForm)request.getAttribute("news_all");%>
       <table>
       <tr><td>主题</td></tr>
              <tr><td><%=f.getTitle()%></td></tr>
              <tr><td><bean:write name="news_all" property="title"  filter="false"/></td></tr>
        <tr><td>时间</td></tr>       
              <tr><td><%=f.getTime()%></td></tr>
        <tr><td>内容</td></tr>     
              <tr><td><bean:write name="news_all" propeXrty="content"  filter="false"/></td></tr>
         <tr><td>计数</td></tr>     
              <tr><td><%=f.getCounter()%></td></tr>     
       </table>
       
       
      </body>
    </html>
    IE栏显示已经读取到ID  IE栏显示 http://localhost:8080/hanz/newsdetail.do?id=6