第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

get方法沒問題,post方法報(bào)405錯(cuò)誤

HTTP Status [405] – [Method Not Allowed]

Type?Status Report

Message?HTTP method POST is not supported by this URL

Description?The method received in the request-line is known by the origin server but not supported by the target resource.

Apache Tomcat/9.0.0.M21

代碼:index.jsp:

<%@?page?language="java"?contentType="text/html;?charset=UTF-8"?pageEncoding="UTF-8"%>
<%??
String?path?=?request.getContextPath();??
String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";??
%>?
<!DOCTYPE?html>
<html>
<head>
<base?href="<%=basePath%>">?
<meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8">
<!--?<link?rel="stylesheet"?type="text/css"?href="">?-->
<title>Insert?title?here</title>
</head>
<body>
<h1>第一個(gè)servlet小例子</h1>
<hr>
<a?href="servlet/HelloServlet">Get方法請(qǐng)求HelloServlet</a>
???<form?action="servlet/HelloServlet"?method="post">
???<input?type="submit"?value="用post方式提交HelloServlet"?/>
???</form>
</body>
</html>


HelloServlet.java:

package?servlet;
import?java.io.IOException;
import?java.io.PrintWriter;
import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
public?class?HelloServlet?extends?HttpServlet?{
@Override
protected?void?doGet(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{
//?TODO?Auto-generated?method?stub
System.out.println("處理Get請(qǐng)求……");
PrintWriter?out?=?response.getWriter();
response.setContentType("text/html;charset=utf-8");
out.println("<b>Hello?Servlet</b>");
}
@Override
protected?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{
System.out.println("處理Post請(qǐng)求……");
PrintWriter?out?=?response.getWriter();
response.setContentType("text/html;charset=utf-8");
out.println("<b>Hello?Servlet</b>");
}
}

web.xml:

<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee?http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!--?歡迎頁面?-->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>servlet.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/servlet/HelloServlet</url-pattern>
</servlet-mapping>
</web-app>


正在回答

4 回答

換個(gè)瀏覽器吧,大概是緩存問題

0 回復(fù) 有任何疑惑可以回復(fù)我~

去掉super.doPost(req, resp);

3 回復(fù) 有任何疑惑可以回復(fù)我~

問題解決了。

代碼沒有錯(cuò),引起錯(cuò)誤的是我的項(xiàng)目里Java Build Path 出了點(diǎn)問題(之前不曉得哪里出了錯(cuò),按照度娘上找的方法,手殘?jiān)邳c(diǎn)了build path,在Libraries那里加了不屬于它的文件,導(dǎo)致項(xiàng)目出錯(cuò)。)。這個(gè)問題解決了就OK了。

Markers報(bào)錯(cuò):Archive for required library: 'WebContent/WEB-INF/web.xml' in project 'ServletDemo' cannot be read or is not a valid ZIP file ServletDemo Build path Build Path Problem

http://img1.sycdn.imooc.com//59376d380001d08b12890344.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~
index.jsp頁面寫錯(cuò)了??不需要servlet/


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Tsukiis 提問者

servlet/去掉就是報(bào)404錯(cuò)誤了
2017-06-06 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JAVA遇見HTML——Servlet篇
  • 參與學(xué)習(xí)       160615    人
  • 解答問題       1086    個(gè)

本門課程在JSP課程的基礎(chǔ)上,深入介紹Servlet的基礎(chǔ)知識(shí)

進(jìn)入課程

get方法沒問題,post方法報(bào)405錯(cuò)誤

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)