今天简单的做了个例子在 response.sendRedirect("list"); 重定向时报 405错误;
原因 :当用servlet类的URL直接访问servlet时,发送的是HTTP请求,servlet默认调用doGet()方法,而源程序里没有重写父类的doGet()方法,父类的doGet()方法不被此种URL支持,所以出现HTTP method GET is not supported by this URL这种错误
解决:ListEmpServlet.java 类重写doge()方法
页面
<form action="addEmp" method="get">
<fieldset>
<legend>新增人员</legend>
姓名:<input name="name"/><br/>
薪水:<input name="salary"/><br/>
年龄:<input name="age"/><br/>
<input type="submit" value="提 交"/>
<input type="reset" value="重 置"/>
</fieldset>
</form>
web.xml
<servlet>
<servlet-name>addEmpServlet</servlet-name>
<servlet-class>servlet.AddEmpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>addEmpServlet</servlet-name>
<url-pattern>/addEmp</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>listEmpServlet</servlet-name>
<servlet-class>servlet.ListEmpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>listEmpServlet</servlet-name>
<url-pattern>/list</url-pattern>
</servlet-mapping>
AddEmpServlet.java
public class AddEmpServlet extends HttpServlet{
public void service(HttpServletRequest request,
HttpServletResponse response) throws
ServletException,IOException{
response.sendRedirect("list");}
ListEmpServlet.java
public class ListEmpServlet extends HttpServlet {
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
//this.doGet(request,response);
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
System.out.println("2");
// this.service(request, response);
this.Server(request, response);
}
public void Server(HttpServletRequest reques,
HttpServletResponse response)throws
ServletException,IOException{
System.out.println("3");
}
相关推荐
java解决405 - HTTP method GET is not supported by this URL
在启动Oracle数据库时提示:ORA-00845 MEMORY_TARGET not supported on this system错误,解决办法
主要介绍了http请求405错误方法不被允许的解决 (Method not allowed),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
解决SVN上传提示Empty directoriesis not supported 解决SVN上传提示Empty directoriesis not supported
pymssql-2.1.1.win-amd64-py2.7.exe
安卓app渗透测试平台,使用请百度,安装:pip2 install drozer-2.4.4-py2-none-any.whl,缺模块使用pip2补充安装即可。
PyHook是一个基于Python的“钩子”库,主要用于监听当前电脑上鼠标和键盘的事件。这个库依赖于另一个Python库PyWin32,如同名字所显示的,PyWin32只能运行在Windows平台,所以PyHook也只能运行在Windows平台。...
In this course, we will get you started with Python data analysis by introducing the basics of data analysis and supported Python libraries such as matplotlib, NumPy, and pandas. Create visualizations...
Called by the server (via the service method) to allow a servlet to handle a GET request. doHead(HttpServletRequest, HttpServletResponse) - Method in class javax.servlet.http.HttpServlet Receives an...
Http-servlet请求完整代码(client-service),以及servlet的“HTTP method GET is not supported by this URL”错误处理
解压 pip install mysqlclient-1.4.6-cp37-cp37m-win32.whl
This is caused by a quirk in WinZip; Apparently WinZip doesn't like IDataObject.GetData to be called before IDropTarget.Drop is called. ------------------------------------------- 5. Support and ...
pyWinhook-1.6.2-cp39-cp39-win32
tesserocr-2.4.0-cp37-cp37m-win32.whl
资源分类:Python库 所属语言:Python 资源全名:pvxslibs-0.2.1-cp39-cp39-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
python 连接 Microsoft SQL Server 驱动,适用python2.7,32位, whl格式,pip install 直接安装,可离线安装。
Later is supported when map2dbg.exe tool is placed in \Bin folder of EurekaLog installation (separate download is required) 5)....Added: Exception2HRESULT in EAppDLL to simplify developing DLLs with ...
离线安装包,测试可用。使用 pip install [完整包名] 进行安装
离线安装包,测试可用。使用 pip install [完整包名] 进行安装
ERROR: pycocotools.whl is not a valid wheel filename. Windows上安装 pycocotools 失败 pip install pycocotools_windows-2.0.0.2-cp38-cp38-win_amd64.whl pip install F:\GoogleDownload\pycocotools_windows-...