由于注重的是整合,所以这里没有写得很完善,没有事务处理,也没有处理业务逻辑的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`...
阅读全文
不得不说,现在的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...
阅读全文
在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']“
阅读全文
Sorry for the great delay in release of Ultimate Edition 3.0. Ultimate Edition 3.0 is unlike any previous release. Ultimate Edition 3.0 was built from Linux Mint 11 ‘Katya’, which in itself was built from Ubuntu 11.04 ‘Natty Narwhal’. I hope I did not lose anyone there. A slew of issues have been resolved. I have dubbed this release ‘ULTAMINT’. It is a real piece of eye-candy and it has a comprehensive software package. I have included repositories from GetDeb, Ubuntu and Linux Mint. I...
阅读全文
最近有报道说mint的关注度已经高过ubuntu,有许多ubuntu粉丝不服。Mint是基于ubuntu,可以说是ubuntu改良后的系统,得到更多人的喜爱也不足为怪。而两者源自同一血统,何必再争高低呢?
借着Mint12的发布,这篇文章来讲解如何在Windows7下硬盘安装Mint12。之前也有写过一篇硬盘安装Mint11,提到了硬盘安装Mint的方法,和ubuntu一致。而在Windows7下一般采用EasyBCD来引导安装,这篇文章介绍另一工具叫做是burg4dos。
如果说Win的grub4dos是Linux的grub1,那么win的burg4dos就是Linux的grub2,这样说就不难理解了。
利用grub2的特点,burg4dos还能再省功夫,所以本文...
阅读全文
Linux Mint 12基于Ubuntu 11.10、Linux 3.0、Gnome 3.2,开发代号Lisa。
下载信息:
Download (SHA256): linuxmint-12-gnome-dvd-32bit.iso (1,027MB, torrent), linuxmint-12-gnome-dvd-64bit.iso (1,017MB, torrent).
Linux Mint 12新功能介绍:New features in Linux Mint 12
Linux Mint 12基于Ubuntu 11.10和Linux 3.0,但不包括Unity桌面。主要新特性包括:GNOME 3和基于GNOME 3的桌面层MGSE,MGSE还不太稳定仍处于早期发展阶段,主要是让GNOME 2用户能以熟悉的方式体验GNOME 3;GNOME 2.32 分支MATE;引入两种新主题;默认搜索引擎Duck Duck Go;等。Linux Min...
阅读全文
Ubuntu11.10 有了许多改进,其中DVD精简至1.5G,这和之前发布的Mandriva2011一样。硬盘安装的方法依然没有改变,熟悉方法的朋友可以照老方法安装。本次要讲解的是在Windows7下硬盘安装Ubuntu11.10,供新手参考学习。
如果你是其它环境可以参考这2篇文章
Linux下硬盘安装Ubuntu11.04全程图解:http://www.linuxsight.com/blog/1472
XP硬盘安装ubuntu10.10全程图解:http://www.linuxsight.com/blog/935
安装开始:
1、下载ubuntu11.10 DVD :http://www.linuxsight.com/blog/2903
2、解压casper文件夹下面的vmlinuz和initrd.lz文件,放到C盘。
3、下载EasyBCD: ht...
阅读全文












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