项目用到Shiro就从网上找一些案例看看吧,结果看了很多都是maven的,没有办法就自己弄了一个。废话不多说,原理自己找开始上菜。

配置web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  3. <context-param>
  4. <param-name>contextConfigLocation</param-name>
  5. <param-value>classpath:applicationContext.xml</param-value>
  6. </context-param>
  7. <listener>
  8. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  9. </listener>
  10. <servlet>
  11. <servlet-name>spring</servlet-name>
  12. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  13. <load-on-startup>1</load-on-startup>
  14. </servlet>
  15. <servlet-mapping>
  16. <servlet-name>spring</servlet-name>
  17. <url-pattern>/</url-pattern>
  18. </servlet-mapping>
  19. <filter>
  20. <filter-name>shiroFilter</filter-name>
  21. <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  22. <init-param>
  23. <param-name>targetFilterLifecycle</param-name>
  24. <param-value>true</param-value>
  25. </init-param>
  26. </filter>
  27. <filter-mapping>
  28. <filter-name>shiroFilter</filter-name>
  29. <url-pattern>/*</url-pattern>
  30. </filter-mapping>
  31. </web-app>

spring-servlet.xml与web.xml同目录

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:mvc="http://www.springframework.org/schema/mvc"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
  7. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  8. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
  9.  
  10. <context:component-scan base-package="com.lkk.shiro"></context:component-scan>
  11.  
  12. <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  13. <property name="prefix" value="/"></property>
  14. <property name="suffix" value=".jsp"></property>
  15. </bean>
  16.  
  17. <mvc:annotation-driven></mvc:annotation-driven>
  18. <mvc:default-servlet-handler/>
  19.  
  20. </beans>

ehcache.xml

  1. <ehcache>
  2.  
  3. <!-- Sets the path to the directory where cache .data files are created.
  4.  
  5. If the path is a Java System Property it is replaced by
  6. its value in the running VM.
  7.  
  8. The following properties are translated:
  9. user.home - User's home directory
  10. user.dir - User's current working directory
  11. java.io.tmpdir - Default temp file path -->
  12. <diskStore path="java.io.tmpdir"/>
  13.  
  14. <cache name="authorizationCache"
  15. eternal="false"
  16. timeToIdleSeconds="3600"
  17. timeToLiveSeconds="0"
  18. overflowToDisk="false"
  19. statistics="true">
  20. </cache>
  21.  
  22. <cache name="authenticationCache"
  23. eternal="false"
  24. timeToIdleSeconds="3600"
  25. timeToLiveSeconds="0"
  26. overflowToDisk="false"
  27. statistics="true">
  28. </cache>
  29.  
  30. <cache name="shiro-activeSessionCache"
  31. eternal="false"
  32. timeToIdleSeconds="3600"
  33. timeToLiveSeconds="0"
  34. overflowToDisk="false"
  35. statistics="true">
  36. </cache>
  37.  
  38. <!--Default Cache configuration. These will applied to caches programmatically created through
  39. the CacheManager.
  40.  
  41. The following attributes are required for defaultCache:
  42.  
  43. maxInMemory - Sets the maximum number of objects that will be created in memory
  44. eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element
  45. is never expired.
  46. timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used
  47. if the element is not eternal. Idle time is now - last accessed time
  48. timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used
  49. if the element is not eternal. TTL is now - creation time
  50. overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
  51. has reached the maxInMemory limit.
  52.  
  53. -->
  54. <defaultCache
  55. maxElementsInMemory="10000"
  56. eternal="false"
  57. timeToIdleSeconds="120"
  58. timeToLiveSeconds="120"
  59. overflowToDisk="true"
  60. />
  61.  
  62. <!--Predefined caches. Add your cache configuration settings here.
  63. If you do not have a configuration for your cache a WARNING will be issued when the
  64. CacheManager starts
  65.  
  66. The following attributes are required for defaultCache:
  67.  
  68. name - Sets the name of the cache. This is used to identify the cache. It must be unique.
  69. maxInMemory - Sets the maximum number of objects that will be created in memory
  70. eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element
  71. is never expired.
  72. timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used
  73. if the element is not eternal. Idle time is now - last accessed time
  74. timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used
  75. if the element is not eternal. TTL is now - creation time
  76. overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
  77. has reached the maxInMemory limit.
  78.  
  79. -->
  80.  
  81. <!-- Sample cache named sampleCache1
  82. This cache contains a maximum in memory of 10000 elements, and will expire
  83. an element if it is idle for more than 5 minutes and lives for more than
  84. 10 minutes.
  85.  
  86. If there are more than 10000 elements it will overflow to the
  87. disk cache, which in this configuration will go to wherever java.io.tmp is
  88. defined on your system. On a standard Linux system this will be /tmp"
  89. -->
  90. <cache name="sampleCache1"
  91. maxElementsInMemory="10000"
  92. eternal="false"
  93. timeToIdleSeconds="300"
  94. timeToLiveSeconds="600"
  95. overflowToDisk="true"
  96. />
  97.  
  98. <!-- Sample cache named sampleCache2
  99. This cache contains 1000 elements. Elements will always be held in memory.
  100. They are not expired. -->
  101. <cache name="sampleCache2"
  102. maxElementsInMemory="1000"
  103. eternal="true"
  104. timeToIdleSeconds="0"
  105. timeToLiveSeconds="0"
  106. overflowToDisk="false"
  107. /> -->
  108.  
  109. <!-- Place configuration for your caches following -->
  110.  
  111. </ehcache>
  1. <ehcache>
  2.  
  3. <!-- Sets the path to the directory where cache .data files are created.
  4.  
  5. If the path is a Java System Property it is replaced by
  6. its value in the running VM.
  7.  
  8. The following properties are translated:
  9. user.home - User's home directory
  10. user.dir - User's current working directory
  11. java.io.tmpdir - Default temp file path -->
  12. <diskStore path="java.io.tmpdir"/>
  13.  
  14. <cache name="authorizationCache"
  15. eternal="false"
  16. timeToIdleSeconds="3600"
  17. timeToLiveSeconds="0"
  18. overflowToDisk="false"
  19. statistics="true">
  20. </cache>
  21.  
  22. <cache name="authenticationCache"
  23. eternal="false"
  24. timeToIdleSeconds="3600"
  25. timeToLiveSeconds="0"
  26. overflowToDisk="false"
  27. statistics="true">
  28. </cache>
  29.  
  30. <cache name="shiro-activeSessionCache"
  31. eternal="false"
  32. timeToIdleSeconds="3600"
  33. timeToLiveSeconds="0"
  34. overflowToDisk="false"
  35. statistics="true">
  36. </cache>
  37.  
  38. <!--Default Cache configuration. These will applied to caches programmatically created through
  39. the CacheManager.
  40.  
  41. The following attributes are required for defaultCache:
  42.  
  43. maxInMemory - Sets the maximum number of objects that will be created in memory
  44. eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element
  45. is never expired.
  46. timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used
  47. if the element is not eternal. Idle time is now - last accessed time
  48. timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used
  49. if the element is not eternal. TTL is now - creation time
  50. overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
  51. has reached the maxInMemory limit.
  52.  
  53. -->
  54. <defaultCache
  55. maxElementsInMemory="10000"
  56. eternal="false"
  57. timeToIdleSeconds="120"
  58. timeToLiveSeconds="120"
  59. overflowToDisk="true"
  60. />
  61.  
  62. <!--Predefined caches. Add your cache configuration settings here.
  63. If you do not have a configuration for your cache a WARNING will be issued when the
  64. CacheManager starts
  65.  
  66. The following attributes are required for defaultCache:
  67.  
  68. name - Sets the name of the cache. This is used to identify the cache. It must be unique.
  69. maxInMemory - Sets the maximum number of objects that will be created in memory
  70. eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element
  71. is never expired.
  72. timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used
  73. if the element is not eternal. Idle time is now - last accessed time
  74. timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used
  75. if the element is not eternal. TTL is now - creation time
  76. overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
  77. has reached the maxInMemory limit.
  78.  
  79. -->
  80.  
  81. <!-- Sample cache named sampleCache1
  82. This cache contains a maximum in memory of 10000 elements, and will expire
  83. an element if it is idle for more than 5 minutes and lives for more than
  84. 10 minutes.
  85.  
  86. If there are more than 10000 elements it will overflow to the
  87. disk cache, which in this configuration will go to wherever java.io.tmp is
  88. defined on your system. On a standard Linux system this will be /tmp"
  89. -->
  90. <cache name="sampleCache1"
  91. maxElementsInMemory="10000"
  92. eternal="false"
  93. timeToIdleSeconds="300"
  94. timeToLiveSeconds="600"
  95. overflowToDisk="true"
  96. />
  97.  
  98. <!-- Sample cache named sampleCache2
  99. This cache contains 1000 elements. Elements will always be held in memory.
  100. They are not expired. -->
  101. <cache name="sampleCache2"
  102. maxElementsInMemory="1000"
  103. eternal="true"
  104. timeToIdleSeconds="0"
  105. timeToLiveSeconds="0"
  106. overflowToDisk="false"
  107. /> -->
  108.  
  109. <!-- Place configuration for your caches following -->
  110.  
  111. </ehcache>

applicationContext.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5.  
  6. <!--
  7. 1. 配置 SecurityManager!
  8. -->
  9. <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
  10. <property name="cacheManager" ref="cacheManager"/>
  11. <property name="realms">
  12. <ref bean="jdbcRealm"/>
  13. </property>
  14. </bean>
  15.  
  16. <!--
  17. 2. 配置 CacheManager.
  18. 2.1 需要加入 ehcache 的 jar 包及配置文件.
  19. -->
  20. <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
  21.  
  22. <property name="cacheManagerConfigFile" value="classpath:ehcache.xml"/>
  23. </bean>
  24.  
  25. <!--
  26. 3. 配置 Realm
  27. 3.1 直接配置实现了 org.apache.shiro.realm.Realm 接口的 bean
  28. -->
  29. <bean id="jdbcRealm" class="com.lkk.shiro.realms.ShiroRealm">
    <!- 加密算法会用到->
  30. </bean>
  31.  
  32. <!--
  33. 4. 配置 LifecycleBeanPostProcessor. 可以自定的来调用配置在 Spring IOC 容器中 shiro bean 的生命周期方法.
  34. -->
  35. <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
  36.  
  37. <!--
  38. 5. 启用 IOC 容器中使用 shiro 的注解. 但必须在配置了 LifecycleBeanPostProcessor 之后才可以使用.
  39. -->
  40. <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
  41. depends-on="lifecycleBeanPostProcessor"/>
  42. <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
  43. <property name="securityManager" ref="securityManager"/>
  44. </bean>
  45.  
  46. <!--
  47. 6. 配置 ShiroFilter.
  48. 6.1 id 必须和 web.xml 文件中配置的 DelegatingFilterProxy 的 <filter-name> 一致.
  49. 若不一致, 则会抛出: NoSuchBeanDefinitionException. 因为 Shiro 会来 IOC 容器中查找和 <filter-name> 名字对应的 filter bean.
  50. -->
  51. <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
  52. <property name="securityManager" ref="securityManager"/>
  53. <property name="loginUrl" value="/login.jsp"/>
  54. <property name="successUrl" value="/list.jsp"/>
  55. <property name="unauthorizedUrl" value="/unauthorized.jsp"/>
  56.  
  57. <!--
  58. 配置哪些页面需要受保护.
  59. 以及访问这些页面需要的权限.
  60. 1). anon 可以被匿名访问
  61. 2). authc 必须认证(即登录)后才可能访问的页面.
  62. 3). logout 登出.
  63. 4). roles 角色过滤器
  64. -->
  65.  
  66. <property name="filterChainDefinitions">
  67. <value>
  68. /login.jsp = anon
  69. /shiro/login = anon
  70. /shiro/logout = logout
  71.  
  72. # everything else requires authentication:
  73. /** = authc
  74. </value>
  75. </property>
  76.  
  77. </bean>
  78.  
  79. </beans>

ShiroHandler.java

  1. package com.lkk.shiro.handlers;
  2.  
  3. import org.apache.shiro.SecurityUtils;
  4. import org.apache.shiro.authc.AuthenticationException;
  5. import org.apache.shiro.authc.UsernamePasswordToken;
  6. import org.apache.shiro.subject.Subject;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10.  
  11. @Controller
  12. @RequestMapping("/shiro")
  13. public class ShiroHandler {
  14.  
  15. @RequestMapping("/login")
  16. public String login(@RequestParam("username") String username,
  17. @RequestParam("password") String password){
  18.  
  19. Subject currentUser = SecurityUtils.getSubject();
  20.  
  21. if (!currentUser.isAuthenticated()) {
  22. // 把用户名和密码封装为 UsernamePasswordToken 对象
  23. UsernamePasswordToken token = new UsernamePasswordToken(username, password);
  24. // rememberme
  25. token.setRememberMe(true);
  26. try {
  27. System.out.println("1. " + token.hashCode());
  28. // 执行登录.
  29. currentUser.login(token);
  30. }
  31. // ... catch more exceptions here (maybe custom ones specific to your application?
  32. // 所有认证时异常的父类.
  33. catch (AuthenticationException ae) {
  34. //unexpected condition? error?
  35. System.out.println("登录失败: " + ae.getMessage());
  36. }
  37. }
  38.  
  39. return "redirect:/list.jsp";
  40. //return "list";
  41. }
  42.  
  43. }

ShiroRealm.java

  1. package com.lkk.shiro.realms;
  2.  
  3. import org.apache.shiro.authc.AuthenticationException;
  4. import org.apache.shiro.authc.AuthenticationInfo;
  5. import org.apache.shiro.authc.AuthenticationToken;
  6. import org.apache.shiro.authc.LockedAccountException;
  7. import org.apache.shiro.authc.SimpleAuthenticationInfo;
  8. import org.apache.shiro.authc.UnknownAccountException;
  9. import org.apache.shiro.authc.UsernamePasswordToken;
  10. import org.apache.shiro.authz.AuthorizationInfo;
  11. import org.apache.shiro.realm.AuthorizingRealm;
  12. import org.apache.shiro.realm.Realm;
  13. import org.apache.shiro.subject.PrincipalCollection;
  14.  
  15. public class ShiroRealm extends AuthorizingRealm{
  16.  
  17. @Override
  18. protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {
  19. // TODO Auto-generated method stub
  20. return null;
  21. }
  22.  
  23. @Override
  24. protected AuthenticationInfo doGetAuthenticationInfo(
  25. AuthenticationToken token) throws AuthenticationException {
  26. // TODO Auto-generated method stub
  27. System.out.println("[FirstRealm] doGetAuthenticationInfo");
  28.  
  29. //1. 把 AuthenticationToken 转换为 UsernamePasswordToken
  30. UsernamePasswordToken upToken = (UsernamePasswordToken) token;
  31.  
  32. //2. 从 UsernamePasswordToken 中来获取 username
  33. String username = upToken.getUsername();
  34.  
  35. //3. 调用数据库的方法, 从数据库中查询 username 对应的用户记录
  36. System.out.println("从数据库中获取 username: " + username + " 所对应的用户信息.");
  37. //4. 若用户不存在, 则可以抛出 UnknownAccountException 异常
  38. if("unknown".equals(username)){
  39. throw new UnknownAccountException("用户不存在!");
  40. }
  41.  
  42. //5. 根据用户信息的情况, 决定是否需要抛出其他的 AuthenticationException 异常.
  43. if("monster".equals(username)){
  44. throw new LockedAccountException("用户被锁定");
  45. }
  46.  
  47. //6. 根据用户的情况, 来构建 AuthenticationInfo 对象并返回. 通常使用的实现类为: SimpleAuthenticationInfo
  48. //以下信息是从数据库中获取的.
  49. //1). principal: 认证的实体信息. 可以是 username, 也可以是数据表对应的用户的实体类对象.
  50. Object principal = username;
  51. //2). credentials: 密码.
  52. Object credentials ="123";
  53. //3). realmName: 当前 realm 对象的 name. 调用父类的 getName() 方法即可
  54. String realmName = getName();
  55.  
  56. SimpleAuthenticationInfo info = null; //new SimpleAuthenticationInfo(principal, credentials, realmName);
  57. info = new SimpleAuthenticationInfo(principal, credentials, realmName);
  58. return info;
  59.  
  60. }
  61.  
  62. }

list.jsp

  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10.  
  11. <h4>hello world</h4>
  12. <a href="shiro/logout">注销</a>
  13.  
  14. </body>
  15. </html>

login.jsp

  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10.  
  11. <h4>Login Page</h4>
  12. <form action="shiro/login" method="POST">
  13. username: <input type="text" name="username"/>
  14. <br><br>
  15.  
  16. password: <input type="password" name="password"/>
  17. <br><br>
  18.  
  19. <input type="submit" value="Submit"/>
  20. </form>
  21. </body>
  22. </html>

第二章加密的源码可以用这个包

http://pan.baidu.com/s/1bp0JRaB

Shiro SpringMVC 非maven HelloWorld的更多相关文章

  1. Eclipse下创建Spring MVC web程序--非maven版

    首先, 安装eclipse和tomcat, 这里我下载的是tomcat9.0版本64位免安装的:地址https://tomcat.apache.org/download-90.cgi 免安装的如何启动 ...

  2. 使用IDEA创建一个SSM工程(非maven)

    说在前面的话 直到现在从Eclipse向IDEA转的人越来越多,但是IDEA的项目创建让人摸不清头脑,因此这里我创建一个非maven的ssm工程,供大家练练手,进一步的了解IDEA在项目中的使用. 创 ...

  3. SSM Spring+SpringMVC+mybatis+maven+mysql环境搭建

    SSM Spring+SpringMVC+mybatis+maven环境搭建 1.首先右键点击项目区空白处,选择new->other..在弹出框中输入maven,选择Maven Project. ...

  4. 将Myeclipse非maven项目,导入到IDEA

    # 将Myeclipse非maven项目,导入到IDEA 1. 打开原项目,复制“.classpath”文件路径,在IDEA中打开项目时,选此文件路径 2. 进入项目转换界面,默认一步步完成 3. 导 ...

  5. IntelliJ IDEA使用心得之非Maven项目篇

    今天和大家分享下非Maven项目在IDEA中的配置方法,由于非Maven项目的配置方法基本相同,所以此篇只对不同点进行说明. 1.声明依赖库 我们可以使用库的方式来添加项目依赖,这是一个非常好的实践. ...

  6. Maven– HelloWorld实例

    Maven– HelloWorld实例 maven安装好后,可以通过HelloWorld项目来体验一下maven是如何构建项目的.Maven项目的核心是pom.xml(就像Ant的build.xml一 ...

  7. Spring+SpringMVC+MyBatis+Maven框架整合

    本文记录了Spring+SpringMVC+MyBatis+Maven框架整合的记录,主要记录以下几点 一.Maven需要引入的jar包 二.Spring与SpringMVC的配置分离 三.Sprin ...

  8. 非maven项目 idea project structure

    原文链接:https://www.cnblogs.com/jajian/p/8081640.html 最近接手非maven项目,需要熟悉idea的project structure,以解决出现的环境报 ...

  9. idea-----Intellij IDEA配置tomcat(非maven项目)

    Intellij IDEA配置tomcat(非maven项目) 引用: https://blog.csdn.net/springlovejava/article/details/78570241 ID ...

随机推荐

  1. C#解析XML详解(XPath以及带命名空间NameSpace)

    <?xml version="1.0" encoding="utf-8" ?> <bookstore> <book> < ...

  2. Xp下麦克风设备及音量检测

    从Vista开始,windows底层的音频架构发生了改变:原本是底层API的waveXXX.mixerXXX等都在Core Audio APIs的基础上进行了重构,上升为了高层API:底层API变为C ...

  3. c语言入门

    c 语言现在是一门很流行的语言,它介于汇编语言和高级语言之间,我认为 它属于中级语言,如c语言 的指针 ,位操作符,等,因为接近于汇编语言,c语言的执行代码效率很高 现在大多数的系统 如unix,和l ...

  4. win10 UWP RSS阅读器

    RSS简易信息聚合(也叫聚合内容)是一种RSS基于XML标准,在互联网上被广泛采用的内容包装和投递协议.RSS(Really Simple Syndication)是一种描述和同步网站内容的格式,是使 ...

  5. uva10003 - Cutting Sticks(简单动规)

    /* * Author: Bingo * Created Time: 2015/2/13 18:33:03 * File Name: uva10003.cpp */ #include <iost ...

  6. UVa 1608,Non-boring sequences

    好诡异的一个题啊 紫书上关于从左边找还是从两边往中间找的讨论没有看懂,怎么一下就找到唯一的元素了(⊙_⊙?) 方法就是用的书上讲的方法,类似于uva 11572,不过这个题需要预处理存下两边的最近的相 ...

  7. 【转】Linux设备驱动--块设备(一)之概念和框架

    原文地址:Linux设备驱动--块设备(一)之概念和框架 基本概念   块设备(blockdevice) --- 是一种具有一定结构的随机存取设备,对这种设备的读写是按块进行的,他使用缓冲区来存放暂时 ...

  8. 【转】深度分析NandFlash—物理结构及地址传送(以TQ2440开发板上的K9F2G08U0A为例)

    K9F2G08U0A是三星公司生产的总容量为256M的NandFlash,常用于手持设备等消费电子产品.还是那句话,搞底层就得会看datasheet,我们就从它的datasheet看起. 这就是 K9 ...

  9. python第四课——线程、进程、协程

    面试or笔试题:简述线程.进程.协程之间的关系? 内容概要 1.进程与线程优.缺点的比较 2.适用情况 3.线程 线程的创建 setDaemon join event RLock 队列 4.进程 创建 ...

  10. (转) Redis学习教程--基本命令

    原文出自:http://www.cnblogs.com/woshimrf/p/5198361.html 目录 全局操作:1.redis是key-value存储的,放在内存中,并在磁盘持久化的数据结构存 ...