应该是路径不对,把jsp和目录结构贴出来看看吧。
解决方案 »
- 刚接触jsp不久现在做项目高手来,求解!!
- 关于swfupload用post_prams传值 不能传中文的问题 知道解决方法的来
- fushionchart多个图表显示不正常的问题
- jdbc链接数据库求助
- Struts中使用<logic:present>标签显示List对象的问题
- POI读取EXCEL导入数据库(带源程序),导入到数据库的时候提示错误,请此方面的高手指点!在线等,急切!
- JFreeChart 时间轴显示范围大小问题?
- 为什么login()这个js无效呢
- 请问jsp中有无分割字符串的函数(同vb中的split()函数)
- Apache Tomcat/4.0.4能支持多少用户?
- Jsp菜鸟诚恳求助:---》
- 提个问题,好像很有意思哟!!(大家都来顶呀)
import java.io.IOException;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import com.bbs.connections.ConnectionFactory;
import com.bbs.bean.MyQuestionBean;public class MyQuestionServlet extends HttpServlet{public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException ,IOException{
HttpSession session=req.getSession();
String userName=(String)session.getAttribute("userName");
int count;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
StringBuffer sql=new StringBuffer();
ConnectionFactory cf=new ConnectionFactory();
try{
conn=cf.getConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql.append("select * from noteTable where");
sql.append(" notewriter='"+userName+"' order by noteLastTime desc");
rs=stmt.executeQuery(sql.toString());
MyQuestionBean Mq=new MyQuestionBean();
while(rs.next()){
Mq.setNoteIDs(Integer.toString(rs.getInt("noteID")));
Mq.setNoteTitles(rs.getString("noteTitle"));
Mq.setNotePics(rs.getString("notePic"));
Mq.setNoteRewriteNums(Integer.toString(rs.getInt("noteRewriteNum")));
Mq.setNoteLastTimes(rs.getString("noteLastTime"));
}
if(conn!=null){
conn.close();
}
req.setAttribute("Mq", Mq);
RequestDispatcher rd=getServletContext().getRequestDispatcher("/myquestion.jsp");
rd.forward(req,res);
} catch(SQLException se){
System.out.println("SQL error");
}
}
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException{
doGet(req,res);
}
}
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="forum.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style2 {color: #009ACE}
-->
</style></head><body>
<jsp:useBean id="Mq" class="com.bbs.bean.MyQuestionBean" scope="request"/>
<jsp:useBean id="Util" class="com.bbs.util.MyUtil"/>
<% String userName=(String)session.getAttribute("userName");%>
<table width="100%" >
<tr>
<td class="postauthor style2">你好<%=userName%>这是你的专家门诊</td>
</tr>
</table>
<table width="100%" height="60" cellpadding="1" cellspacing="1" bgcolor="#000000" >
<tr>
<td width="5%" height="25" bgcolor="#009ACE" class="postauthor style1"><div align="center">状态</div></td>
<td width="72%" bgcolor="#009ACE" class="postauthor style1"><div align="center">主题</div></td>
<td width="6%" bgcolor="#009ACE" class="postauthor style1"><div align="center">回复</div></td>
<td width="17%" bgcolor="#009ACE" class="postauthor style1"><div align="center">最后回复时间</div></td>
</tr>
<%
Vector notes=Mq.getNoteIDs();
for(int i=0;i<notes.size();i++){
String noteID=Mq.getNoteIDs(i);
String noteTitle=Mq.getNoteTitles(i);
String notePic=Mq.getNotePics(i);
String noteRewriteNum=Mq.getNoteRewriteNums(i);
String noteLastTime=Mq.getNoteLastTimes(i);
int RewriteNum=Integer.parseInt(noteRewriteNum);
noteTitle=Util.ex_chinese(noteTitle);
noteLastTime=Util.ex_chinese(noteLastTime);
noteLastTime=(noteLastTime=="")?noteLastTime:noteLastTime.substring(2,15);
String pic=(RewriteNum==0)?"image/folder.gif":"image/istop.gif";
%>
<tr>
<td height="30" bgcolor="#FFFFFF"><div align="center"><img src=<%=pic%> width="18" height="16"> </div></td>
<td bgcolor="#FFFFFF"><div align="left"> <img src="image/<%=notePic.trim()%>.gif" width="15" height="15"/><a href="note.jsp?noteID=<%=noteID%>"><%=noteTitle%></a> </div></td>
<td bgcolor="#FFFFFF"><div align="center"><%=noteRewriteNum%> </div></td>
<td bgcolor="#FFFFFF"><div align="center"><%=noteLastTime%> </div></td>
</tr>
<%}%>
</table></body>
</html>
css,按照这个url当然取不到css了.
你可以考虑用绝对路径,很多网站都这样做的。