2017-03-15 24 views
-2

Eclipseで私はfollowing Spring MVC projectでしたが、サーバーで実行するとリソース(画像、CSS、jsなど)の負荷が問題になりました。 。Spring MVC - HTTPリクエスト(リソース用)のマッピングが見つかりません

org.springframework.web.servlet.DispatcherServlet noHandlerFound ませマッピング名 'dispacciatore' でのDispatcherServletにURI [/ProgettoTecWeb/<c:url value=]でHTTPリクエストが見つかり: 私はmvc:resources mapping追加しましたが、私はJSP実行したときに、私に言う日食

解決策はありますか?ありがとう!

web.xmlの

<web-app id = "WebApp_ID" version = "2.4" 
xmlns = "http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

    <display-name>Talent Show</display-name> 

    <servlet> 
     <servlet-name>dispacciatore</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>dispacciatore</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 

</web-app> 

dispacciatore-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"> <context:annotation-config /> <context:component-scan base-package="it.uniparthenope"/> <!-- Vado a settare il package dove andrò a mettere la mia classe java che farà da home Controller. --> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".jsp" /> </bean> <mvc:view-controller path="/" view-name="index"/> <mvc:resources mapping="/resources/**" location="/resources/" cache-period="31556926"/> <mvc:annotation-driven /> </beans> 

index.jspを

<link href="<c:url value='/resources/assets/css/style.css"/>" rel="stylesheet"> 
... 
    <script src="<c:url value="/resources/assets/js/custom.js"/>"></script> 

答えて

0

index.jspからリソースを呼び出す際に誤字があるようです。

あなたは現在この

<link href="<c:url value='/resources/assets/css/style.css"/>" rel="stylesheet"> 

代わりの

<link href="<c:url value="/resources/assets/css/style.css"/>" rel="stylesheet"> 

それが役立ちますかどうかを参照してくださいように呼びかけている:それはまた、引用符に問題

ご注意かもしれません。 あなたが実際にそれは春

+0

あなたが実際にJSTLタグなしでパスを与えることができ、それは春にうまく動作します – BabyHulk

0

Controllerクラス用のパッケージを作成し、RequestMappingアノテーションを使用してHTTPマッピングに配線する必要があります。最後に、コンポーネントスキャンを使用して、特定のコントローラパッケージを指定します。それは動作するはずです。

0
  1. プロジェクト内だけで正常に動作し、JSTLタグなしでパスを与えることができます - >パスをビルド - >のconfigure構築パス - >を追加し、サーバーランタイム
  2. は、Javaのバージョンが最新に実行されている変更します
  3. Windown - >ビューの表示 - >問題 - >クイックフィックスすべての問題
関連する問題