springMvc有する.2 project2.ssm登録機能を実装した。従属記述子(web.xmlの)プロファイル

1. A下位ディスクリプタ(web.xmlの)構成

代わりに/の1.1urlパターン設定/ *

/ *最後の.jspファイルは、要求が失敗したように、内蔵のプロセッササーブレット要求をインターセプトし、転送し、独自にする場合は様々なリクエストを処理するTomcatのサーブレットは、内蔵された、独自のを持っています

1.2ロード時間のDispatcherServletのカスタマイズ

することができる<servlet>で追加され<load-on-startup>1</load-on-startup>て配置DispatcherServletのロードされたサーバの起動、書き込み要求が最初に到着した場合の負荷が発生したときにHTTP

1.3カスタムSpringMvcプロファイルのパス

<servlet>書き込み<init-param> <param-name>contextConfigLocation</param-name><parm-value>url</parm-value></init-param>

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>project2</display-name>
  
  <servlet>
  	<servlet-name>springMvc</servlet-name>
  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>springMvc</servlet-name>
  <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

2SpringMvcプロフィール

2.1ワイルドカードの構成は非常に包括的ですが、注釈解決策を見つけることができません

平均豆にこれら2つの設定文に参加MVCはhttp://www.springframework.org/schema/mvc/spring-mvc.xsdを解決するために、このファイルを使用しています

xmlns:MVC =「http://www.springframework.org/schema/mvc」
XSIます:http://www.springframework.org/schema/mvc/spring-mvc.xsd「>

2.2 springMvcは、UTF-8形式のコンフィギュレーションファイル宣言応答をコード

UTF-8の第1のパラメータgetMessageConverters(要素、ソース、parserContext)に割り当てを実行HttpMessageConverter書き込み方法、HttpMessageConverter中に呼び出され意味する前面のデータ・タイプ・マッチングのための方法及び後端インタラクション情報であり、そこに5つの方法:canRead、読み取り、書き込み、canWrite、getSupportedMediaTypes

<mvc:annotation-driven>
	<mvc:message-converters>
		<bean class="org.springframework.http.converter.StringHttpMessageConverter">
			<constructor-arg index="0" value="utf-8"></constructor-arg>
		</bean>
	</mvc:message-converters>
</mvc:annotation-driven>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd ">
<mvc:annotation-driven>
	<mvc:message-converters>
		<bean class="org.springframework.http.converter.StringHttpMessageConverter">
			<constructor-arg index="0" value="utf-8"></constructor-arg>
		</bean>
	</mvc:message-converters>
</mvc:annotation-driven>
<context:component-scan base-package="com.project2"></context:component-scan>

</beans>
リリース7件のオリジナルの記事 ウォンの賞賛0 ビュー64

おすすめ

転載: blog.csdn.net/weixin_43458072/article/details/104213773