2012-02-15 14 views
-2

web.XMLのようなWeb-INFフォルダに配置するための基本的なXML設定ファイルと、view resolver beanの作成場所を知る必要があります。基本的なSpring MVCアプリケーションを実行するための設定またはXMLファイルは何ですか?

コントローラの登録方法を教えてください。

アプリケーションを実行すると、「サーブレットコンテキストリソースを開けませんでした」というエラーが表示されます。サーブレット・コンテキスト・リソースとは何ですか?

私のweb.xmlは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 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"> 

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

<servlet-mapping> 
<servlet-name>springmvc</servlet-name> 
<url-pattern>*.html</url-pattern> 
</servlet-mapping> 
<welcome-file-list> 
<welcome-file> 
jsp/index.jsp 
</welcome-file> 


</welcome-file-list> 
</web-app> 

私springmvcは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 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-2.5.xsd"> 

<bean name="/hello_world.html" class="springmvc.web.HelloWorldController"/> 
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> 
<property name="prefix" value="/jsp/"/> 
<property name="suffix" value=".jsp"/> 
</bean> 
</beans> 

私はこれらの2つのXMLファイルを持っています。

私は春の設定ファイルも必要と知っています。私はそれに何を入れる必要があるのか​​分かりません。

+2

春には非常に良い文書があります。あなたはおそらくそれを読むべきです。 – bezmax

+0

@Max私はリファレンスドキュメント(http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/)も好きです。しかし残念なことに、この文書では、アプリケーションを設定する方法について説明していません。 – Ralph

答えて

0

STS(Spring Tool Suite)を使用している場合、Springテンプレートプロジェクトを作成できます。 (新しいプロジェクト/ SpringSourceツールスイート/ Springテンプレートプロジェクト/ -Spring MVCプロジェクト)

これには、開始する必要があるすべてのファイルが含まれています。

関連する問題