簡體   English   中英

消息:此URL不支持HTTP方法POST

[英]message: HTTP method POST is not supported by this URL

在任何人由於缺乏研究試圖將其標記為重復或標記之前,我承認這個問題已經在堆棧溢出中存在,但是提供的解決方案不能解決我的問題,因此我想看看人們是否可以解決我遇到的這個獨特問題。

這是我的表格

<form:form method="POST" action="addQuestion" >

   <input type="text" name="questionId" />Enter Id<br>
   <input type="text" name="theQuestion" />Enter Q <br>
   <input type="text" name="category" />Enter Category<br>
   <input type="text" name="correctAnswer" />Enter correct answer<br>
   <input type="submit" value="Next"  >

</form:form>

這出現在我的web.xml中

<servlet>
        <servlet-name>addQ</servlet-name>
        <servlet-class>main.WebController</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>addQ</servlet-name>
        <url-pattern>/addQuestion</url-pattern>
    </servlet-mapping>

這是我的網絡控制器

@RequestMapping("/addQuestion")
        public String addQuestion(ModelMap model, @RequestParam(value="question", required = true)  String theQuestion , @RequestParam(value="questionId", required = true)  Integer questionId, @RequestParam(value="category", required = true)   String category, @RequestParam(value="correctAnswer", required = true)   String correctAnswer) throws SQLException{
            ViewController viewController = new ViewController();
            viewController.createQuestion(questionId, theQuestion, category, correctAnswer);
            model.addAttribute("message", "Hello hope this flipping works");

        return "addQuestion";
    }

並且我收到的錯誤消息是此URL不支持HTTP方法POST

做這個:

@RequestMapping(value="/addQuestion", method=RequestMethod.POST)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM