junit 安装 springmvc+hibernate(13)

电脑杂谈  发布时间:2018-02-07 19:32:08  来源:网络整理

acctUser.setNickName("andy");

acctUser.setRegisterTime(new Date());

acctUser.setTelephone("13022221111");

String id = userService.save(acctUser);

LOGGER.info(JSON.toJSONString(id));

}

}

添加spring-mvc.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:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/beans

">

<!-- 自动扫描@Controller注入为bean -->

<context:component-scan base-package="com.controller" />

<!-- 以下为SpringMVC配置 -->

<mvc:annotation-driven>

<!-- 返回json数据,@response使用 -->

<mvc:message-converters register-defaults="true">

<bean

>

<property>

<list>

<value>text/html;charset=UTF-8</value>

<value>application/json;charset=UTF-8</value>

</list>

</property>

</bean>

</mvc:message-converters>

</mvc:annotation-driven>

<!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->

<bean

>

<property

value="org.springframework.web.servlet.view.JstlView" />

<property value="/WEB-INF/views" />

<property value=".jsp" />

</bean>

</beans>

上面配置了包扫描Controller,[emailprotected]??,和视图层的配置。

web容器是web项目的大脑,所以web容器,首先需要引入spring,让spring管理各个框架,并将其注入为bean。然后配置控制层的filter信息。并且配置了springmvc拦截的url为以.hmls结尾的请求。


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-65857-13.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...