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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我在 spring restcontroller 示例中遇到錯誤

我在 spring restcontroller 示例中遇到錯誤

小唯快跑啊 2021-12-10 15:42:00
這幾天我正在學習 Java Spring。我正在做一個關于 Spring 和 Rest Api 的簡單示例。我想將“Hello World”寫入瀏覽器。我使用了 @restController 。我可以為我的示例找到任何解決方案。我的Java代碼package webgroup.webartifact;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloWorldController {    @RequestMapping(value="/getHelloWorld")    @ResponseBody    public String getHelloWorld() {        return "Hello World ";    }}我的 xml 文件是<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:mvc="http://www.springframework.org/schema/mvc"    xmlns:context="http://www.springframework.org/schema/context"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="        http://www.springframework.org/schema/beans             http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/mvc         http://www.springframework.org/schema/mvc/spring-mvc.xsd        http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context.xsd">    <context:component-scan base-package="webgroup.webartifact"/>    <context:annotation-config />    <bean class= "org.springframework.web.servlet.view.InternalResourceViewResolver" >        <property name= "prefix">            <value>/WEB-INF/</value>        </property>        <property name= "suffix">        <value>.jsp</value>        </property>    </bean>  </beans>  當我運行這個項目時,給我一個 http 狀態(tài) 500 錯誤。我搜索錯誤,但我沒有解決方案。
查看完整描述

2 回答

?
尚方寶劍之說

TA貢獻1788條經(jīng)驗 獲得超4個贊

它抱怨找不到類org.springframework.http.MediaType。

此類打包在spring-web api 中,該 API 與您在 pom.xml 文件中作為依賴項添加的spring-webmvc捆綁在一起。所以你不應該得到錯誤。

取出彈簧網(wǎng)絡的依賴,無需添加隱式,因為它是添加了彈簧webmvc如上所述,這將覆蓋彈簧網(wǎng)被添加了彈簧webmvc。確保 pom.xml 文件中沒有錯誤,然后運行mvn installmvn package下載所有依賴項。


查看完整回答
反對 回復 2021-12-10
?
慕虎7371278

TA貢獻1802條經(jīng)驗 獲得超4個贊

您能否從您的 pom 中刪除 spring-web 依賴項并將 spring 版本升級到 4.3.2 并且請@ResponseBody從您的控制器方法中刪除注釋,因此它在那里沒有用


查看完整回答
反對 回復 2021-12-10
  • 2 回答
  • 0 關注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號