sping+springmvc+mybatis登录
来源:互联网 发布:知乎 坠井 编辑:程序博客网 时间:2024/06/05 04:50
1.spring+mybatis代码
spring+mybatis代码
2.web.xml
<?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_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>springMVCDemo</display-name> <!-- 监听spring上下文容器 --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <!-- 加载spring的xml配置文件到 spring的上下文容器中 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> <!-- 配置DispatchcerServlet --> <servlet> <servlet-name>springDispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置Spring mvc下的配置文件的位置和名称 --> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMVC.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springDispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list></web-app>3.controller
/** * */package com.jit.test.controller;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import com.jit.test.model.User;import com.jit.test.servicedao.ServiceDao;import com.jit.test.servicedaoimpl.ServiceDaoImpl;/** * @author sue wong * 2017年8月6日下午1:49:26 * since v1.0 */@Controllerpublic class LoginController {@Autowiredprivate ServiceDao servicedao;//private User user;private String s;/** * @return the servicedao */public ServiceDao getServicedao() {return servicedao;}/** * @param servicedao the servicedao to set */public void setServicedao(ServiceDao servicedao) {this.servicedao = servicedao;}@RequestMapping("/login")public String Login(String username,String password){System.out.println("sssssssss");try {User u=new User();u.setUsername(username);u.setPassword(password);System.out.println(u.getUsername());if(servicedao.validLogin(u)){s="success";}else{s= "error";}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return s;}}
4.springMVC.xml
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"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/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 配置自动扫描的包 --> <context:component-scan base-package="com.jit.test.controller"></context:component-scan> <!-- 配置视图解析器 如何把handler 方法返回值解析为实际的物理视图 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name = "prefix" value="/"></property> <property name = "suffix" value = ".jsp"></property> </bean> </beans>
5.jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title></head><body><form action="login" method="post"> username:<input type="text" name = "username" ><p> password:<input type="password" name = "password" ><p> <input type="submit" value="登录"> </form></body></html>
6.效果图
阅读全文
0 0
- sping+springmvc+mybatis登录
- sping+springmvc+mybatis+shiro,配置文件
- springmvc+mybatis登录功能
- Sping,SpringMVC,Mybatis 三大框架整合环境搭建详解
- SSH(Sping,Struts2,Hibernate)和SSM(Sping,SpringMVC,MyBatis)的比较
- Spring+SpringMVC+Mybatis(登录)
- springmvc+mybatis+oracle简单登录
- sping-mybatis事物
- SpringMVC + Mybatis 实现用户登录功能
- shiro-springmvc-mybatis登录认证 权限控制
- SpringMVC Spring Mybatis Maven 实现登录功能
- Spring+SpringMVC+Mybatis+shiro权限登录管理
- SSM(Spring+SpringMVC+Mybatis)登录实例
- SpringMVC+Spring+mybatis 实现登录过程(使用后台验证框架)
- springmvc+mybatis+sql server实现简单登录功能
- springmvc+mybatis+sql server实现简单登录功能
- spring+springmvc+mybatis整合之登录+文件上传
- springmvc+spring+mybatis(简单登录)+aop日志管理
- java判断手机号运营商
- 抽象工厂(abstract_factory)c++版
- 代码干货 | perl信号量实现进程间通信
- mysql编码问题汇总
- 移动端网页实现拨打电话功能的几种方法以及点击立刻qq联系
- sping+springmvc+mybatis登录
- wave文件(*.wav)格式、PCM数据格式
- servlet的实现
- 编译工程报错:duplicate symbol _KNSemiModalTransitionStyle
- 简单理解数据库游标cursor
- springMVC对静态资源访问的处理
- office2016 mac破解版,亲测可用
- protobuf初步
- angularjs下上传文件组件flowjs