我的工程是jsp+javaBean+servlet做的.
在我的index.jsp点击注册之后进入注册页面.填写好后.点击提交.要求链接servlet.
servlet文件的名称是LoginServlet.java.之后我在web.xml里面注册了一下.在JSP页面里面我只要用Login_Servlet就可以用了(action ="Login_Servlet").可是现在http://localhost:8080/test之后提示我Servlet文件找不到.为什么?
我的文件路径为:
工程
|
|-->index.jsp
|-->system
|-->login.jsp
|
|
|-->web-inf
|-->../../servlet/login/LoginServlet.java
当我点击提交之后,我的http://localhost:8080/test/system/Login_Servlet
出现错误.
HTTP Status 404 - /test/system/Login_Servlet -------------------------------------------------------------------------------- type Status report message /test/system/Login_Servlet description The requested resource (/test/system/Login_Servlet) is not available.
-------------------------------------------------------------------------------- Apache Tomcat/5.5.17
那位大侠能帮帮我.我刚刚开始学东西.现在做毕业设计.就是搞不定呀.
可以的话告诉我为什么出错.如何改.
在我的index.jsp点击注册之后进入注册页面.填写好后.点击提交.要求链接servlet.
servlet文件的名称是LoginServlet.java.之后我在web.xml里面注册了一下.在JSP页面里面我只要用Login_Servlet就可以用了(action ="Login_Servlet").可是现在http://localhost:8080/test之后提示我Servlet文件找不到.为什么?
我的文件路径为:
工程
|
|-->index.jsp
|-->system
|-->login.jsp
|
|
|-->web-inf
|-->../../servlet/login/LoginServlet.java
当我点击提交之后,我的http://localhost:8080/test/system/Login_Servlet
出现错误.
HTTP Status 404 - /test/system/Login_Servlet -------------------------------------------------------------------------------- type Status report message /test/system/Login_Servlet description The requested resource (/test/system/Login_Servlet) is not available.
-------------------------------------------------------------------------------- Apache Tomcat/5.5.17
那位大侠能帮帮我.我刚刚开始学东西.现在做毕业设计.就是搞不定呀.
可以的话告诉我为什么出错.如何改.
你的上下文根是什么?
你的表单的action属性是什么?
你在web.xml中队servlet的映射是什么?
我要详细点的信息。
index.jsp里的action="/项目名称/servlet 的URL(在web.xml里<servlet-url>的值"
<servlet-mapping>
<servlet-name>TestServelet</servlet-name>
<url-pattern>/servlet/TestServlet</url-pattern>
</servlet-mapping>
这样的话 action应该是 action="servlet/TestServlet"
问你几个问题:
你的上下文根是什么?
你的表单的action属性是什么?
你在web.xml中队servlet的映射是什么?
我要详细点的信息。
1.我的问题只要一个.就是servlet的路径问题.我搞不定.
2.我的上下文是:/test.
3.我的表单的action的属性是:POST.
4.我在web.xml中servlet的映射是:
<web-app>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>project.com.servlet.login.LoginServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>LogonServlet</servlet-name>
<servlet-class>project.com.servlet.logon.LogonServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/Login_Servlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LogonServlet</servlet-name>
<url-pattern>/Logon_Servlet</url-pattern>
</servlet-mapping>
</web-app>
关于映射我只能给你提供这些.
我知道是小问题,可是我就是搞不定啊.我都好几天了在这个问题上绕.
没找到工程名吧
你要用绝对路径来访问是最稳妥的,当然用相对路径也可以,. 和 ..的搭配使用
如楼上的
每个jsp页面不是有这个吗
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
用action=" <%=basePath%>Login_Servlet"
可是我的index.jsp填写用户名和密码,点击登录.action里面我用Logon_Servlet就可以呢?
难道因为我的JSP文件路径会影响吗?
我的index.jsp在:我的工程/index.jsp里面,login.jsp在:我的工程/system/login.jsp.
当我点击提交我注册的信息时,url变成了http://localhost:8080/test/system/Login_Servlet呢?
然后它就报错了,说:
type Status reportmessage /test/system/Login_Servletdescription The requested resource (/test/system/Login_Servlet) is not available.
结果是http://localhost:8080/test/Login_Servlet.可是页面什么也没有.是空白.
应该是通过servlet进行数据库操作.然后提交另外一个页面的呀.
那么 action="Logon_Servlet" 就可以了
对应的超连接 <a href="Logon_Servlet">aaaaaaa</a> 也一样
你的问题不复杂的,照着写,多写几遍 你就知道问题出在哪里了
servlet访问还有一种访问方法 直接用http://localhost:8080/servlet/包名.文件名访问