以后我的非技术类日志都要配图了. 在这里做个记号. 一般是我自己随性画的草图, 所以大家不要太期望.
-
2006-10-31
以后我的非技术类日志都要配图了
Views: 8525 | No Comments -
2006-10-27
凉爽的天气
Views: 10696 | 1 Comment今天中午的时候天气很好. 在我们吃完午饭时, 离下午的金属工艺实习的时间还有1个半钟头. 我的同学去教室里趴着睡觉, 不过我觉得教室里空气太干燥所以不愿意去.
我在体育场前树荫底下坐下. 虽然有点冷, 不过我不想坐在阳光底下, 因为那样会让我的身体特别干燥而难受. 天气就在凉爽和冷之间. 我挽起衣袖, 在风中遐想着, 便不觉得冷了.
体育场离我住的地方很远, 所以我不经常来. 不过它就在图书馆旁边, 所以我每星期都经过一两次. 天气还不错, 心情不坏.
-
2006-10-19
Because I Love You 及其吉他谱
Views: 27920 | 1 CommentBecause I Love You If I got down on my knees and I'm pleaded with you. If I crossed a million oceans just to be with you. Would you ever, let me down? If I climbed the highest mountain just to hold you tight. If I said that I will love you every single night. Would you ever, let me down? Well I'm sorry, it would sound kind of sad/bad, just that. I'm worry, so worry, that you let me down. Because I love you, love you. I love you, so don't let me down. If I swam the longest river just to call your name. If I said the way I feel for you would never change. Would you ever, fool around? Well I'm sorry, it would sound kind of bad, just that. I'm worry, so worry, that you let me down. Because I love you, love you. I love you, so don't let me down. Well I'm sorry, it would sound kind of bad, just that. I'm worry, so worry, that you let me down. Because I love you, love you, love you, love you...
这首歌很简单, 伴奏可以说只用了4个和弦.下面的谱是我从VCD上扒下来的, 你多听几遍就应该知道怎么弹唱.
-
2006-10-15
idea’s rms 已经发布, 赶快下载吧
Views: 12022 | 5 Commentsidea's rms(idea's resource management system)是一个在线资源管理系统. 使用GPLv2许可证发布. 所以你可以得到它的源代码. idea's rms 使用java/jsp开发, 基于Spring和Hibernate框架.
idea's rms 的典型应用是:
- 作为资源共享和资源发布的平台, 在互联网上提供文件给别人查看和下载.
- 作为企业内部文件共享的平台.
- 作为学校发布教学课件的平台.
-
2006-10-13
Je m’appelle Hélène 我的名字叫做依莲
Views: 12184 | No Comments当我从实验室走到建筑与艺术馆, 心想已经迟到了, 该怎么进入音乐基础课的教室, 对面教室传来了清脆的歌声. 我探头想看看, 门口两个学生问:"你好, 你是来听法语讲座的吗?". 歌声还在唱着, 我便不由自主地走进去. 投影屏幕上显示在播放一首歌, 但我无法看出歌名. 我回头问身后的学生:"嗨, 你好. 你知道这首歌叫什么名吗?"
"依莲." 她说.
"你知道是谁唱的吗?" 我问, 因为我曾经听过, 但是不知道歌名, 一直找不到.
"不知道" 她说.
我心想着既然我没有机会和时间学习法语, 那今晚就听听吧. 所以我的音乐基础课就不上了.
-- Hélène Rollès Hélène 依莲 Je m'appelle Hélène 我叫依莲 Je suis une fille 我是一个女孩子 Comme les autres 和其他的女孩一样 Hélène 依莲 J'ai mes joies mes peines 我也有我的快乐我的烦恼 Elles font ma vie 这些组成我的生活 Comme la votre 就像你们一样 Je voudrais trouver l'amour 我的愿望是找到爱情 Simplement trouver l'amour 就只是找到爱情 Hélène 依莲 Je m'appelle Hélène 我叫依莲 Je suis une fille 我是一个女孩子 Comme les autres 和其他的女孩一样 Hélène 依莲 Si mes nuits sont pleines 如果说我的夜晚是充满 De rêves de poémes 诗一样的梦 Je n'ai rien d'autre 除此以外 我一无所有 Je voudrais trouver l'amour 我的愿望是找到爱情 Simplement trouver l'amour 就只是找到爱情 Et même 假如 Si j'ai ma photo 我的照片 Dans tous les journaux 每周都出现在 Chaque semaine 所有的报纸上 Personne 没有人 Ne m'attend le soir 在夜里等我 Quand je rentre tard 当我晚归的时候 Personne ne fait battre mon coeur 没有人让我伤心 Lorsque s'eteignent les projecteurs 当镭射灯熄灭的时候 Hélène Je m'appelle Hélène Je suis une fille Comme les autres Je voudrais trouver l'amour 我的愿望是找到爱情 Simplement trouver l'amour 就只是找到爱情 Et même 甚至 Quand à la télè 当你们在电视上 Vous me regardez 看着我 Sourire et chanter 微笑和歌唱 Personne 没有人 Ne m'attend le soir 在夜里等我 Quand je rentre tard 当我晚归的时候 Personne ne fait battre mon coeur 没有人让我伤心 Lorsque s'eteignent les projecteurs 当镭射灯熄灭的时候 Hélène Je m'appelle Hélène Je suis une fille Comme les autres Hélène 依莲 Et toutes mes peines 总有那么一天 Trouveront l'oubli 所有我的烦恼 Un jour ou l'autre 都会被忘记 Quand je trouverai l'amour 当我找到爱情的时候 Quand je trouverai l'amour 当我找到爱情的时候 Quand je trouverai l'amour 当我找到爱情的时候 Quand je trouverai l'amour 当我找到爱情的时候
-
2006-10-08
Web应用中基于组的用户权限管理在Spring框架下的实现
Views: 27650 | 4 Comments在几乎所有的web应用中都需要对访问者(用户)进行权限管理, 因为我们希望某些页面只对特定的用户开放, 以及某些操作只有符合身份的用户才能进行. 这之中涉及到了身份验证和权限管理. 只有单用户系统和多用户单权限系统才不需要权限管理.
在本文中, 使用了基于组的权限管理, 并在Spring框架下利用HandlerInterceptorAdapter和Hibernate进行实现.
User的结构是:
public class User { private int id; private String name; private String password; private Set<String> groups = new HashSet<String>(); }
UserGroup表:
user:int group:String
使用联合主键, 在Java中没有对应的类.
Hibernate映射文件是:
<hibernate-mapping auto-import="true" default-lazy="false"> <class name="net.ideawu.User" table="User"> <cache usage="read-write" /> <id name="id" column="id"> <generator class="native"/> </id> <property name="name" column="name"/> <property name="password" column="password"/> <set name="groups" table="UserGroup" cascade="save-update" lazy="false"> <key column="user" /> <element column="`group`" type="string" /> </set> </class> </hibernate-mapping>
一切的身份验证交给一个继承HandlerInterceptorAdapter的类来做:
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.util.UrlPathHelper; import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; ... public class AuthorizeInterceptor extends HandlerInterceptorAdapter { private UrlPathHelper urlPathHelper = new UrlPathHelper(); private PathMatcher pathMatcher = new AntPathMatcher(); private Properties groupMappings; /** * Attach URL paths to group. */ public void setGroupMappings(Properties groupMappings) { this.groupMappings = groupMappings; } public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String url = urlPathHelper.getLookupPathForRequest(request); String group = lookupGroup(url); // 找出资源所需要的权限, 即组名 if(group == null){ // 所请求的资源不需要保护. return true; } // 如果已经登录, 一个User实例被保存在session中. User loginUser = (User)request.getSession().getAttribute("loginUser"); ModelAndView mav = new ModelAndView("system/authorizeError"); if(loginUser == null){ mav.addObject("errorMsg", "你还没有登录!"); throw new ModelAndViewDefiningException(mav); }else{ if(!loginUser.getGroups().contains(group)){ mav.addObject("errorMsg", "授权失败! 你不在 <b>" + group + "</b> 组!"); throw new ModelAndViewDefiningException(mav); } return true; } } /* * 查看 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.lookupHandler() * Ant模式的最长子串匹配法. */ private String lookupGroup(String url){ String group = groupMappings.getProperty(url); if (group == null) { String bestPathMatch = null; for (Iterator it = this.groupMappings.keySet().iterator(); it.hasNext();) { String registeredPath = (String) it.next(); if (this.pathMatcher.match(registeredPath, url) && (bestPathMatch == null || bestPathMatch.length() <= registeredPath.length())) { group = this.groupMappings.getProperty(registeredPath); bestPathMatch = registeredPath; } } } return group; } }
下面我们需要在Spring的应用上下文配置文件中设置:
<bean id="authorizeInterceptor" class="net.ideawu.AuthorizeInterceptor"> <property name="groupMappings"> <value> <!-- Attach URL paths to group --> /admin/*=admin </value> </property> </bean> <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="interceptors"> <list> <ref bean="authorizeInterceptor" /> </list> </property> <property name="mappings"> <value> /index.do=indexController /browse.do=browseController /admin/removeArticle.do=removeArticleController </value> </property> </bean>
注意到"/admin/*=admin", 所以/admin目录下的所有资源只有在admin组的用户才能访问, 这样就不用担心普通访客删除文章了. 使用这种方法, 你不需要在removeArticleController中作身份验证和权限管理, 一切都交给AuthorizeInterceptor.