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
阅读全文
下载地址:
openSUSE-Edu-li-f-e-12.1-1-i686.iso (2,929MB, MD5, torrent).
openSUSE Education team is proud to present another version of openSUSE – Edu Li-f-e (Linux for Education) based on openSUSE 12.1. Li-f-e comes loaded with everything that students, parents, teachers and system administrators of educational institutions may need. Software for mathematics, chemistry, astronomy and servers, like KIWI-LTSP, Fedena school ERP, Moodle course management, full multimedia, graphics, office suite, many popular programm...
阅读全文
Linux Deepin 11.12 最终版已经正式发布了,此次发现,Deepin的LOGO也变了。
下载地址:
Download (MD5): deepin_11.12_zh-hans_i386.iso (654MB), deepin_11.12_zh-hans_amd64.iso (684MB).
更多下载:http://www.linuxdeepin.com/download
Linux Deepin 11.12 正式版
发布时间:2011-12-30
文件大小:654M(32位),684M(64位)
MD5(32位): d7f9597b6c210fb686d49d24cb684f06
MD5(64位): cd11009e6726f2766d50a8079d793ee1
与 Linux Deepin 11.06 版本相比,Linux Deepin 11.12 版本具有很多值得关注的变化。
一、Deepin 桌面
Linux Deepin 11.12 使用了Gnone Shell...
阅读全文
CentOS 6.1 发布仅一个多星期,6.2就发布了。CentOS项目的开发者显然过去几天一直在熬夜辛苦加班工作。
下载信息:
Download the installation DVD images: CentOS-6.2-i386-bin-DVD1.iso (3,640MB, SHA256, torrent), CentOS-6.2-x86_64-bin-DVD1.iso (4,218MB, SHA256, torrent).
其他:
http://isoredirect.centos.org/centos/6/isos/i386/
http://isoredirect.centos.org/centos/6/isos/x86_64/
阅读全文
在此总结一下近期发布的4大Linux发行版硬盘安装引导写法。
Windows(xp/win7)用户可以用burg4dos(引导文件在安装目录X:\Burg\burg.cfg)
Linux用户必须用Ubuntu/Mint或者Fedora16等采用grub2的发行版(可用 sudo gedit /boot/grub/grub.cfg)
1、首先把所有ISO分别命名成ubuntu11.10.iso、fedora16.iso、opensuse12.1.iso、mint12.iso
放在某个目录如第一硬盘第一个逻辑分区则为(hd0,5)。((hd0,1)表示第一硬盘第一个主分区,以此类推)
2、编辑引导文件,写法如下:
menuentry “硬盘安装 Ubuntu 11.10″ –class ubuntu {
insmod ntfs
...
阅读全文
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...
阅读全文










最新评论
就是repo
楼上,Linux中这个最厉害
试一试先,opensuse不
分区不能是NTFS,那我就等
怎么不行的,装不拉,我试过了
安装了可是桌面没有应用程序的
good
我也是这样的,就是不知道怎么