由于注重的是整合,所以这里没有写得很完善,没有事务处理,也没有处理业务逻辑的service层等,更适合初学者学习。
1、接口UserDAO以及实现类UserDAOImpl。主要是hibernate和spring的整合,提供数据增删查改的操作。
UserDAO.java
package com.linuxsight.dao;
import java.util.List;
public interface UserDAO {
public void insert(Object o) throws Exception;
public List<Object> list() throws Exception;
public void update(Object o) throws Exception;
public void delete(int id) throws Exception;
public Object queryById(int id) throws...
阅读全文
1 准备数据库。由于用到了hibernate,自然少不了数据库,我们这里建立一个简单的表以做演示,ubuntu下的mysql我们已经安装好了,用户名root,密码123456。
把s2sh.sql放到/home/linuxsight目录中
linuxsight@linuxsight-ODM:~$ pwd
/home/linuxsight
linuxsight@linuxsight-ODM:~$ mysql -uroot -p123456 < s2sh.sql
s2sh.sql
create database s2sh
character set 'utf8'
collate 'utf8_general_ci';
use s2sh;
CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`age` int(11) NOT NULL,
PRIMARY KEY (`id`...
阅读全文
Sabayon Linux 8 发布了
下载信息:
Download: Sabayon_Linux_8_x86_K.iso (2,269MB, MD5, torrent), Sabayon_Linux_8_x86_G.iso (1,778MB, MD5, torrent), Sabayon_Linux_8_x86_Xfce.iso (1,438MB, MD5, torrent), Sabayon_Linux_8_amd64_K.iso (2,450MB, MD5, torrent), Sabayon_Linux_8_amd64_G.iso (1,969MB, MD5, torrent), Sabayon_Linux_8_amd64_Xfce.iso (1,631MB, MD5, torrent).
阅读全文
既然用PClinuxOS推荐还是用KDE,虽然它也有gnome,官方也推荐用KDE。
PCLinuxOS KDE and KDE-MiniME 2012.02 are now available for download. These are 32-bit quarterly update ISO images which can also be installed on 64-bit computers. Features: Linux kernel 2.6.38.8bfs kernel for maximum desktop performance; full KDE 4.6.5 desktop; NVIDIA and ATI fglrx drivers support; multimedia playback support for many popular formats; wireless support for many network devices; printer support for many local and networked printer devices; Ad...
阅读全文
不得不说,现在的Mint很火。我本人用Mint都喜欢用GNOME2,而有人也独爱KDE,那Mint 12 “KDE”就适合你了。
The team is proud to announce the release of Linux Mint 12 KDE. Linux Mint 12 KDE comes with updated software and brings refinements and new features to make your desktop even more comfortable to use. This edition comes with the latest and recently released KDE 4.7.4. This is the first release of Linux Mint using Hybrid ISO images. Traditionally, tools such as ‘Startup Disk Creator’ or ‘UNetboo...
阅读全文
Struts2为我们提供了丰富的拦截器,而实现自定义拦截器也是容易的一件事。
拦截器必须是无状态的,原因是Struts2不能保证为每一个请求或者action创建一个实例,所以如果拦截器带有状态,会引发并发问题。
实际应用中处理权限问题是常见的,下面就以一个拦截器来判断处理用户是否登录而有权限去执行action的内容。
LoginInterceptor.java
package com.linuxsight.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class L...
阅读全文
文件上传这个功能在项目应用是非常常见的,这节说说Struts2如何实现文件上传。
Struts2使用开源项目Apache Jakarta Commons FileUpload和内建的FileUploadInterceptor拦截器实现文件上传
下面介绍代码:
FileUploadAction
package com.linuxsight.action;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
public class FileUploadAction {
private File upload;
private String uploadFileName;
private String uploadContentType;
priva...
阅读全文
本节记录了一些struts2的知识点。
1、设置开发调试
struts.properties
struts.devMode = true
添加struts2-config-browser-plugin-2.3.1.jar
地址访问:http://localhost:8080/struts2T1/config-browser/index.action
使用标签<s:debug/>显示
地址访问:
http://localhost:8080/struts2/linuxsight.action?debug=xml
http://localhost:8080/struts2/linuxsight.action?debug=console
2、在struts.properties更换struts2默认主题
struts.ui.theme=simple//主题设为simple,不会在生成多余的html代码
3、struts2运行时变量查找顺序
default.properties
strut...
阅读全文
本节介绍在ubuntu上开发的一个struts2应用。
新建一个web项目,利用myeclipse9.1给我们提供的struts2支持,搭建环境。
这里注意不要勾选多余的jar包,我们只需要core
myeclipse9.1集成的Sturts版本是struts2.2.1
代码如下:
web.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”3.0″
xmlns=”http://java.sun.com/xml/ns/javaee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
http://java.sun.com/x...
阅读全文
本系列文章带来的是在Ubuntu11.10下开发Struts2程序学习过程所记录的滴滴点点,当中所写的也许不能算是学习的好教程,但所涉及的知识点相信会对学习Struts2有一定的帮助。
首先是在Ubuntu11.10搭建开发环境,相信大部分开发者都是在XP下完成的,比较少涉及Linux平台,如果你是用Ubuntu系统的,那可以看看本节内容。
1、安装myeclipse(由于myeclipse已经自带了Tomcat,所以我们不需要再去下载Tomcat了。)
最新的myeclipse已经是myeclipse10了,不过我这里用的myeclipse9.1。
下载地址:http://www.linuxsight.com/blog/2525
安装方法:
linuxsight@linuxsight-ODM:...
阅读全文
Ubuntu默认不能解压RAR文件,Ubuntu11.10也一样,所以我们需要安装软件来支持。
压缩功能
安装 sudo apt-get install rar
卸载 sudo apt-get remove rar
解压功能
安装 sudo apt-get install unrar
卸载 sudo apt-get remove unrar
linuxsight@linuxsight-ODM:~$ sudo apt-get install unrar
[sudo] password for linuxsight:
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
下列【新】软件包将被安装:
unrar
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 330 个软件包未被升级。
需要下载 107 kB 的...
阅读全文
我们知道部署LMAP在任何Linux版本下都可以用源码安装来完成,而当我们用上ubuntu/fedora/opensuse这类发行版可以借助它们的包管理机制来完成,以减轻我们的工作量。
下面介绍在ubuntu11.10下安装配置MySQL、Apache、PHP5、phpMyAdmin的方法
安装MySQL
sudo apt-get install mysql-server
安装Apache
sudo apt-get install apache2
安装PHP5
sudo apt-get install php5 //安装PHP5
其它模块
sudo apt-get install libapache2-mod-php5//配置APACHE+PHP
sudo apt-get install libapache2-mod-auth-mysql//让apache支持mysql
sudo apt-get install php5-mysql //mysql...
阅读全文
Gentoo Linux 12.0 发布了
The live DVD features a superb list of packages, such as Linux kernel 3.1.5, X.Org Server 1.10.4, KDE 4.7.4, GNOME 3.2.1, Xfce 4.8, Fluxbox 1.3.2, Firefox 9.0, LibreOffice 3.4.99.2, GIMP 2.6.11, Blender 2.60, Amarok 2.5, VLC 1.1.13, Chromium 16.0 and much more. Special features: writable file systems using Aufs so you can emerge new packages; persistence for $HOME is available. The live DVD is available in two flavors: a hybrid x86/x86_64 edition, and an x86_64 multi-lib edition
下载信息:
Downl...
阅读全文
在Ubuntu11.10下,打开Windows的TXT乱码,按照以往的方法,在gconf-editor设置下并没有找到相应的选项
解决乱码方案:
打开终端输入:
linuxsight@linuxsight-ODM:~$ gsettings set org.gnome.gedit.preferences.encodings auto-detected “['UTF-8', 'GB18030', 'GB2312', 'GBK', 'BIG5', 'CURRENT', 'UTF-16']“
阅读全文
Dreamlinux 是基于debian的发行版,采用xfce桌面,拥有Mac OS风格主题的系统,在Linux视野也常有提到,大家可以看看有关Dreamlinux的文章
2012年的到来,也迎来了Dreamlinux 5的发布。
下载地址
Dreamlinux-5.iso (965MB, MD5).
更多下载:http://dreamlinux.net/
介绍请见:http://www.linuxsight.com/blog/2475
阅读全文










最新评论
这样安装需不需要先给w
xp果然不行.....
各位想在Linux装o
为什么我会卡在第八步啊,我都
我用的是笔记本电脑,无线网卡
谢谢 啊 第一次看你你的文
怎样解锁手机啊
怎样搞中文啊??