大家都知道JAVA里最流行的是MVC模型的编程方式,如果你不知道MVC的概念,可以去网上搜索下,应该会马上找到N多资料。PHP5推出之后,也开始使用MVC模式开发,看来MVC确实有很大的吸引力!
我在平时开发ASP项目的时候,也借鉴了JAVA的这个开发模式,虽然实现的不是很好,但也使代码结构清晰了不少,大大方便了美工修改程序!
下面是我的代码,具体说明看注释。
程序主要实现是后台管理员的操作:添加,删除,修改
分两个程序,adminusers_class.asp,adminusers_gl.asp
相当于JAVA力一个servlet,一个bean!所以没有完全的实现MVC,只是模拟了一下!
adminusers_class.asp代码如下:
<%
rem *****************通用网站管理系统***********************************
rem 页面功能:网站后台管理员管理类
rem @author 蔡晓亮
rem @version 1.0
rem @date 2005-2-22
%>
<%
'管理员管理类
Class AdminUsersGl
Dim ASO
Private adminuser_name
Private adminuser_password
Private admingroup_id
Private adminuser_isshow
Private adminuser_selfconfig
Private adminuser_realname
'构造函数开始
Private Sub Class_Initialize
Set ASO=Server.CreateObject("Adodb.RecordSet")
End Sub
'析构函数开始
Private Sub Class_Terminate
Err.Clear
Set ASO=Nothing
End Sub
'添加管理员
Public Function AdminUsers_Add(adminuser_name,adminuser_password,admingroup_id,adminuser_realname,adminuser_selfconfig,adminuser_isshow,adminuser_language)
sql="select adminuser_name from ce_adminusers where adminuser_name='"&adminuser_name&"'"
ASO.Open sql,conn,1,3
if ASO.RecordCount<>0 then
Response.Redirect("messages.asp?mess_name=DATA_ADD_FAILURE&back_page=adminusers_gl.asp?action=add")
end if
if ASO.RecordCount=0 then
ASO.Close
sql="insert into ce_adminusers(adminuser_name,adminuser_password,admingroup_id,adminuser_realname,adminuser_selfconfig,adminuser_isshow,adminuser_language) values('"&adminuser_name&"','"&adminuser_password&"',"&admingroup_id&",'"&adminuser_realname&"','"&adminuser_selfconfig&"','"&adminuser_isshow&"','"&adminuser_language&"')"
Response.Write(sql)
ASO.Open sql,conn,1,3
Response.Redirect("messages.asp?mess_name=ADD_SUCCESS&back_page=adminusers_gl.asp?action=add")
ASO.Close
end if
End Function
'取得某管理员信息
Public Function AdminUsers_Xx(adminuser_id)
sql="select adminuser_id,adminuser_name,adminuser_password,admingroup_id,adminuser_isshow,adminuser_selfconfig,adminuser_language,adminuser_realname from ce_adminusers where adminuser_id="&adminuser_id
ASO.Open sql,conn,1,3
if ASO.RecordCount=0 then
Response.Redirect("messages.asp?mess_name=GET_Xx_FAILURE&back_page=adminusers_gl.asp?action=list")
else
adminuser_name=ASO("adminuser_name")
adminuser_password=ASO("adminuser_password")
admingroup_id=ASO("admingroup_id")
adminuser_isshow=ASO("adminuser_isshow")
adminuser_selfconfig=ASO("adminuser_selfconfig")
adminuser_language=ASO("adminuser_language")
adminuser_realname=ASO("adminuser_realname")
end if
ASO.close
End Function
'修改某管理员
Public Function AdminUsers_Modideal(adminuser_id,adminuser_name,adminuser_password,admingroup_id,adminuser_isshow,adminuser_selfconfig,adminuser_language,adminuser_realname)
sql="update ce_adminusers set adminuser_name='"&adminuser_name&"',adminuser_password='"&adminuser_password&"',admingroup_id="&admingroup_id&",adminuser_isshow='"&adminuser_isshow&"',adminuser_selfconfig='"&adminuser_selfconfig&"',adminuser_language='"&adminuser_language&"',adminuser_realname='"&adminuser_realname&"' where adminuser_id="&adminuser_id
response.Write(sql)
ASO.Open sql,conn,1,3
Response.Redirect("messages.asp?mess_name=MODIFY_SUCCESS&back_page=adminusers_gl.asp?action=list")
ASO.Close
End Function
'取得管理员列表
Public Function AdminUsers_List()
sql="SELECT ce_admingroups.admingroup_name, ce_adminusers.adminuser_id,ce_adminusers.adminuser_name, ce_adminusers.adminuser_logintimes, ce_adminusers.adminuser_isshow FROM ce_admingroups INNER JOIN ce_adminusers ON ce_admingroups.admingroup_id = ce_adminusers.admingroup_id"
ASO.Open sql,conn,1,3
while not ASO.eof
if ASO("adminuser_isshow")="Y" then
show="是"
else
show="否"
end if
response.write"
'删除管理员
Public Function AdminUsers_Del(adminuser_id)
sql="delete from ce_adminusers where adminuser_id="&adminuser_id
ASO.Open sql,conn,1,3
Response.Redirect("messages.asp?mess_name=DEL_SUCCESS&back_page=adminusers_gl.asp?action=list")
ASO.Close
End Function
'获取所有管理员组列表
Public Function Get_AdminGroups()
sql="select admingroup_id,admingroup_name from ce_admingroups where admingroup_language='"&LANGUAGE&"' order by admingroup_id asc"
ASO.Open sql,conn,1,3
response.Write(" ")
ASO.Close
End Function
'获取所有管理员组列表,并选中当前所在管理员组
Public Function Get_AdminGroups_S()
sql="select admingroup_id,admingroup_name from ce_admingroups where admingroup_language='"&LANGUAGE&"' order by admingroup_id asc"
ASO.Open sql,conn,1,3
response.Write(" ")
ASO.Close
End Function
'公用属性,供外部程序调用
Public Property Get AUName
AUName = adminuser_name
End Property
Public Property Get AUPassword
AUPassword = adminuser_password
End Property
Public Property Get AUGroupid
AUGroupid = admingroup_id
End Property
Public Property Get AUIsshow
AUIsshow = adminuser_isshow
End Property
Public Property Get AUSelfconfig
AUSelfconfig = adminuser_selfconfig
End Property
Public Property Get AURealname
AURealname = adminuser_realname
End Property
End Class
%>
adminusers_gl.asp代码如下:
<%
rem *****************通用网站管理系统***********************************
rem 页面功能:网站后台管理员添加修改表单
rem @author 蔡晓亮
rem @version 1.0
rem @date 2005-2-22
%>
<%
Response.Buffer=true
Response.Expires=0
%>
<%
action=trim(replace(request("action"),"'",""))
Set GL = New AdminUsersGl '建立类的实例
%>
<%
if action="add" then
adminuser_name=trim(replace(request("adminuser_name"),"'",""))
adminuser_password=md5(trim(replace(request("adminuser_password"),"'","")),32)
admingroup_id=trim(replace(request("admingroup_id"),"'",""))
adminuser_realname=trim(replace(request("adminuser_realname"),"'",""))
adminuser_selfconfig=trim(replace(request("adminuser_selfconfig"),"'",""))
adminuser_isshow=trim(replace(request("adminuser_isshow"),"'",""))
adminuser_language=LANGUAGE
if adminuser_name<>"" then
GL.AdminUsers_Add adminuser_name,adminuser_password,admingroup_id,adminuser_realname,adminuser_selfconfig,adminuser_isshow,adminuser_language
end if
end if
if action="modi" then
adminuser_id=trim(replace(request("adminuser_id"),"'",""))
GL.AdminUsers_Xx adminuser_id
end if
if action="modideal" then
adminuser_id=trim(replace(request("adminuser_id"),"'",""))
adminuser_name=trim(replace(request("adminuser_name"),"'",""))
adminuser_password_n=trim(replace(request("adminuser_password_n"),"'",""))
adminuser_password_o=trim(replace(request("adminuser_password_o"),"'",""))
admingroup_id=trim(replace(request("admingroup_id"),"'",""))
adminuser_isshow=trim(replace(request("adminuser_isshow"),"'",""))
adminuser_selfconfig=trim(replace(request("adminuser_selfconfig"),"'",""))
adminuser_realname=trim(replace(request("adminuser_realname"),"'",""))
adminuser_language=LANGUAGE
if adminuser_id<>"" and adminuser_password_n<>"" then
adminuser_password_n=md5(adminuser_password_n,32)
'response.Write(adminuser_password_n)
GL.AdminUsers_Modideal adminuser_id,adminuser_name,adminuser_password_n,admingroup_id,adminuser_isshow,adminuser_selfconfig,adminuser_language,adminuser_realname
end if
if adminuser_id<>"" and adminuser_password_n="" then
'response.Write(adminuser_password_n&"cxl")
GL.AdminUsers_Modideal adminuser_id,adminuser_name,adminuser_password_o,admingroup_id,adminuser_isshow,adminuser_selfconfig,adminuser_language,adminuser_realname
end if
end if
if action="del" then
adminuser_id=trim(replace(request("adminuser_id"),"'",""))
GL.AdminUsers_Del adminuser_id
end if
%>
<%
title="管理员管理"
css=""
body=""
ShowHeadHtml title,LANGUAGE,css,body '调用公用函数产生头部代码
%>
今天eclipse突然报了com/genuitec/eclipse/j2eedt/core/J2EEProjectUtil 错误,并且工程文件打不开了,在网上找了一下资料,然后按照方法操作了一遍,好了,解决方法如下:
错误提示信息:
An error has occurred.See error log for more details.
Reason:
com/genuitec/
Java使用按值传递的函数调用方式,这往往使我感到迷惑。因为在基础数据类型和对象的传递上,我就会纠结于到底是按值传递,还是按引用传递。其实经过学习,Java在任何地方,都一直发挥着按值传递的本色。
首先,让我们看一看基础数据类型是如何按值传递的。
public static void main(String[] args) {
int a = 2;
Implicits work like this: if you call a method on a Scala object, and the Scala compiler does not see a definition for that method in the class definition for that object, the compiler will try to con
工作与生产效率:
A. 背景声音
Noisli:背景噪音与颜色生成器。
Noizio:环境声均衡器。
Defonic:世界上任何的声响都可混合成美丽的旋律。
Designers.mx:设计者为设计者所准备的播放列表。
Coffitivity:这里的声音就像咖啡馆里放的一样。
B. 避免注意力分散
Self Co