0
以下是我的代码。我拥有webcontent root和css文件夹内的所有css文件。如何在jsp文件中写入servlet代码中应用css文件?
String cssLocation = request.getContextPath() + "/WebContent/css/style.css";
String cssTag = "<link rel='stylesheet'<img class=gallery_img'> type='text/css' href=' "+ cssLocation +" '>";
out.println("<h4> <p><div class='gallery_img'> " + rs.getString("title") + "</div></div></P></h4>");
out.println("");
out.println("<a href='#'><div style='float:left;width:10% border:10px solid;padding:20px ;'><link rel='stylesheet' type='text/css' href='css/style.css'><table style='width:50%' ><td><img width='230' height='230' src=displayphoto?id=" + rs.getString("id") + " style='opacity: 1'></img></td></table></body></a> <p/>");
这是非常糟糕的做法..你不应该混淆表示层代码和后端代码。接下来的人会触摸这个将会非常不高兴。 – Serhiy
感谢您的回复。你能给我发一些关于我的查询的链接 –