日期:2014-05-18 浏览次数:20716 次
<!-- 添加注解驱动 -->
<mvc:annotation-driven />
<!-- 使Spring支持自动检测组件,如注解的Controller 这里只能扫描controller包如果扫描了service包 则事务会失效 -->
<context:component-scan base-package="china.home.daughter.*.*.controller*"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<!-- spring mvc 配置 -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/spring/spring3mvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
@RequestMapping(value = "/login.html", method = RequestMethod.GET)
public String login(HttpServletRequest request, HttpServletResponse response, User user) {
User user2 = userService.getUserByUserNamePassword(user.getUsername(), user.getPassword());
if (null != user2) {
User user3 = new User();
user3.setUsername(CommonUtil.getUUID());
user3.setPassword("");
// 保存方法
userService.saveUser(user3);
// 更新用户
user2.setRealName("JeffreyJi");
userService.updateUser(user2);
// 获取user
logger.info(CommonUtil.isNull(userService.getUserById(user2.getId())) + "");
}
if (null != user2) {
logger.info(user2.toString());
request.getSession().setAttribute("user", user2);
} else {
}
logger.info("请求成功!");
return "main1/main1";///WEB-INF/jsp/ 下有文件夹main1 下面有 main1.jsp
}