<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。
</a>
从Mysql中查出来的title,点击新闻标题,跳转到新闻的具体内容(content),struts根据.do跳转不是很清楚,我做的点击新闻标题后显示空白页.IE栏 出现的是http://localhost:8080/hanz/newsdetail.do。
<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 自动处理过的连接.
你的ie栏应该是http://localhost:8080/hanz/newsdetail.do?id=...。
你的id应该放入href="newsdetail.do?id=..."之中吧,你怎么写外边去了
修改成<a href="newsdetail.do?id= <bean:write name="n" property="id"/>">
但出现错误org.apache.jasper.JasperException: /news.jsp(36,18) Attribute propeXrty invalid for tag write according to TLD
我要的效果就是点击新闻标题,跳转到news.jsp,news.jsp显示该标题的内容,内容从数据库查出
<a href="newsdetail.do?id= <bean:write name="n" property="id"/>">
<%@ 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