完整代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--启动注解识别,是对包进行扫描,实现注释驱动Bean定义,同时将bean自动注入容器中使用-->
<context:annotation-config/>
<!--后台controller程序的路径-->
<context:component-scan base-package="com.controller"/>

<!--开通静态资源的访问,即jsp或html文件-->
<mvc:default-servlet-handler/>
<!--让所有的Controller能够解析,不可缺少,<mvc:annotation-driven>里面那一整段,用来解决@ResponseBody传输字符串中文乱码问题-->
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 视图解析器/定位 -->
<bean ></beans>

部分截图如下:

dispatcher-servlet.xml文件配置模板

 






相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2022-02-08
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2021-05-29
  • 2021-07-28
  • 2021-11-18
  • 2022-12-23
  • 2018-02-01
相关资源
相似解决方案