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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法訪問(wèn) Spring 控制器

無(wú)法訪問(wèn) Spring 控制器

慕妹3146593 2022-01-12 14:46:36
我正在嘗試從頭開(kāi)始創(chuàng)建一個(gè)非?;镜膽?yīng)用程序的 Spring RESTful API,但我無(wú)法訪問(wèn)控制器。我可以訪問(wèn) JSP 文件但不能訪問(wèn)控制器。我也嘗試過(guò)注釋,@RestController但它沒(méi)有用。我在Tomcat 8上運(yùn)行。錯(cuò)誤是:源服務(wù)器沒(méi)有找到目標(biāo)資源的當(dāng)前表示或不愿意透露存在的表示。WEB.xml    <?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  <listener>    <listener-class>        org.springframework.web.context.ContextLoaderListener    </listener-class>  </listener>      <servlet>        <servlet-name>dispatcher</servlet-name>        <servlet-class>            org.springframework.web.servlet.DispatcherServlet        </servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>    <servlet-mapping>        <servlet-name>dispatcher</servlet-name>        <url-pattern>/</url-pattern>    </servlet-mapping></web-app>調(diào)度程序-servlet.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">    <mvc:annotation-driven />    <context:component-scan        base-package="com.controller />    <mvc:default-servlet-handler /></beans>
查看完整描述

2 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊

如果要單獨(dú)創(chuàng)建應(yīng)用程序上下文,則應(yīng)提供上下文參數(shù)和值作為 context.xml 文件的位置。


<listener>

    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>/WEB-INF/application-context.xml</param-value>

</context-param>

對(duì)于您的錯(cuò)誤,控制器無(wú)法訪問(wèn),可能是由于:-


<context:component-scan

    base-package="com.controller />

檢查您是否編寫(xiě)了正確的基本包名稱或嘗試使用


<context:component-scan base-package="..package name..">

<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>

</context:component-scan>

希望能幫助到你。


查看完整回答
反對(duì) 回復(fù) 2022-01-12
?
慕姐4208626

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊

從 web.xml 中刪除偵聽(tīng)器,因?yàn)槟挥幸粋€(gè)上下文 xml。如果要加載多個(gè)上下文 xml,請(qǐng)?zhí)砑觽陕?tīng)器和上下文參數(shù)。


查看完整回答
反對(duì) 回復(fù) 2022-01-12
  • 2 回答
  • 0 關(guān)注
  • 209 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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