を働いていないコントローラと外部のjarファイルを追加し、私はここにURL春は
を扱うスプリングコントローラコントローラコードが
あるimport org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@EnableWebMvc
@Controller
public class SmartContentValidator {
@RequestMapping(value = "/validate")
public String validate() {
System.out.println("Yo");
return "YO";
}
}
を持つJavaプロジェクトは、その後、私はjarファイルとしてJavaプロジェクトの上にエクスポートしてきました。 その後、新しいWebプロジェクトを作成し、ビルドパスに上記のjarファイルを追加しました。ここでweb.xmlおよびディスパッチャ-servlet.xml
web.xmlの
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SmartContentValidatorTest</display-name>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
ディスパッチャ-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com" />
<context:annotation-config/>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
です今私はhttp://localhost:8080/project_name/validate
をヒットしようとすると、それはブラウザと私のEclipseのコンソールで
WARNING: No mapping found for HTTP request with URI [/SmartContentValidatorTest/validate/] in DispatcherServlet with name 'dispatcher'
で見つかった404-ません示しています。
問題点は何ですか?何か不足していますか?通常、これは正しくコントローラを見つけていない春によって引き起こされる
編集
あなたはこの問題への解決策を見つけました。もしそうなら、答えを書いてください。私は同じ問題を抱えている。 – Darshana