开始的页面用frameset分上,左,右三层,然后在左边的板块写树形菜单,在右边的板块显示点击树形菜单后的类容。
现在我在左边树形菜单上写连接时,我想通过servlet跳转,但是根本就跳转不过。我问一下是不是用frameset后就不能忘servlet跳转了啊?(路径没有问题)
现在我在左边树形菜单上写连接时,我想通过servlet跳转,但是根本就跳转不过。我问一下是不是用frameset后就不能忘servlet跳转了啊?(路径没有问题)
解决方案 »
- 在一个类中还可以定义另一个类吗?文中:private class ResultListener implements DocumentListener在类中定义
- 各位大哥过来看看 简单spring问题
- java格式疑问
- 怎样实现java程序为James邮件服务器创建和删除用户。
- 如何检测java application的 memory leak?
- 我安装了MyEclipse6.0.1all_in_one,想用它学习j2ee,大家推荐些书(网上的资料也行),入门的,谢谢大家
- 比较怪异的问题,附件上传问题
- hibernate数据类型问题
- Hibernate问题
- 帮忙
- 求指点 JDBC 连接oracle出现异常
- 音频文件上传之后播放不了的怎么办?
import java.io.PrintWriter;
import java.lang.reflect.Method;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class DispatchServlet extends HttpServlet { /**
* Constructor of the object.
*/
public DispatchServlet() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gbk");
String action=request.getParameter("action");
try {
Method method=this.getClass().getDeclaredMethod(action, HttpServletRequest.class,HttpServletResponse.class);
method.invoke(this, request,response);
} catch (Exception e) {
e.printStackTrace();
}
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}}
public class MemberServlet extends DispatchServlet {
public void showTopic(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("gbk");
response.setContentType("text/html");
TopicBiz tb = new TopicBiz();
request.setAttribute("tb", tb);
response.sendRedirect("admin/checkTopic.jsp");
}
}
jsp代码:<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gbk">
<TITLE></TITLE>
<STYLE type="text/css">
DIV {
FONT-SIZE: 12px; COLOR: #000000; LINE-HEIGHT: 22px;
}
A{FONT-SIZE: 13px; COLOR: #000000; TEXT-DECORATION: none}
A:hover {FONT-SIZE: 13px; COLOR: #999999}
.red {color: #FF0000}
</STYLE>
<SCRIPT language="JavaScript">
function show(d1){
if(document.getElementById(d1).style.display=='none'){
document.getElementById(d1).style.display='block'; //触动的层如果处于隐藏状态,即显示
}
else{document.getElementById(d1).style.display='none'; //触动的层如果处于显示状态,即隐藏
}
}
</SCRIPT>
</HEAD><BODY><div style="padding-left:10px;">
<DIV ><A href="check.jsp" target="main""><IMG src="../image2/z-1.jpg" border="0" align="middle" >用户管理</A></DIV>
<div><a href="checkBoard.jsp" target="main"><IMG src="../image2/z-2.jpg" border="0" align="middle">板块管理</a></div>
<div><a href="addBoard.jsp" target="main"><IMG src="../image2/z-2.jpg" border="0" align="middle">添加板块</a></div>
<DIV><A href="MemberServlet?action=showTopic" target="main"><IMG src="../image2/z-3.jpg" border="0" align="middle">帖子管理</A></DIV>
</DIV>
</BODY>
</HTML>
那就是路徑問題呀,你訪問servlet,給相對路徑。<a href="<%request.getContextPath()%>/xxServlet">xxx</a>
什么意思啊?
10樓這個人我認識,他叫zfz