`
安静的转着
  • 浏览: 11137 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
oracle帐户命令 oracle, db
-- 查询所有用户
select * from all_users;
-- 查询ORACLE_SID
select * from v$instance;
-- 查询ORACLE SERVERNAME
select * from v$services;
动态引入JS文件 js, jquery
方法一:
<script>
	(function() {
		var bsa = document.createElement('script');
		bsa.async = true;
		bsa.src = 'http://www.red-team-design.com/js/adpacks-demo.js';
		(document.getElementsByTagName('head')[0] || 
			document.getElementsByTagName('body')[0]).appendChild(bsa);
	})();
</script>

方法二:

<script>
	$.getScript(url, function(){
		alert('加载script');
	}):
</script>
mysql 添加用户及权限 mysql
添加用户并授权:
(1)新建数据库
CREATE DATABASE dbName;

(2)添加任何机器都能登录的用户
GRANT ALL PRIVILEGES ON dbName.* TO test@"%" identified by "1111";

(3)添加172.16.184.233机器登录的用户
GRANT ALL ON dbName.* TO test@172.16.184.233 IDENTIFIEDBY "1111"; 

(4)添加 一个用户 授 增 删 改 查 的权限。
GRANT SELECT,INSERT,DELETE,UPDATE ON dbName.* TO test@% IDENTIFIEDBY "1111";

可以只添加单个权限,只拥有查询权限
GRANT SELECT ON dbName.* TO test@% IDENTIFIEDBY "1111";

(5)添加只能访问dbName数据库中t表
GRANT ALL PRIVILEGES ON dbName.t TO test@"%" identified by "1111";
div层会随滚动条移动永久置顶 css
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>why?</title>
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow" />
<style type="text/css" media="screen">
<!--
* {margin:0;padding:0;}
body {margin:0 auto;font:12px/20px tahoma Simsun Arial;color:#fff;background-color:#FFF;text-align:center;}
.aaa{ width:150px; background:Blue;position:absolute;left:0;top:0; }
.bbb{ width:150px; background:Blue;position:absolute;right:0;top:0; }
.ccc{ width:150px; position:absolute; top:100%;left:0; margin-top:-20px;  background:Blue;}
.ddd{ width:150px; position:absolute; top:100%;right:0; margin-top:-20px;  background:Blue;}
.aa{ 
	width:50px; 
	position:fixed; 
	background:Black; 
	_position:absolute;
	_top:expression(eval(document.documentElement.scrollTop));
	z-index:1000;left:0;top:0; 
}
.bb{ width:50px; position:fixed; background:Black; _position:absolute;_top:expression(eval(document.documentElement.scrollTop));z-index:1000;right:0;top:0; }

.cc{
	width:50px; 
	position:fixed; 
	background:Black; 
	_position:absolute;
	_top:expression(eval(document.documentElement.scrollTop));
	z-index:1000;
	left:0;
	top:100%;
	margin-top:-20px;
}
.dd{
	width:50px; 
	position:fixed; 
	background:Black; 
	_position:absolute;
	_top:expression(eval(document.documentElement.scrollTop));
	z-index:1000;
	left:100%;
	margin-left:-50px;
	top:100%;
	margin-top:-20px;
}
.a{ color:#000; }
  -->
</style>
</head>
<body>
<div class="aaa">AAA</div>
<div class="bbb">BBB</div>
<div class="aa">A</div>
<div class="bb">B</div>
<div class="cc">C</div>
<div class="dd">D</div>
<div class="a">
<br />
<br />
<br />
<br />
<br />
A层和B层会随滚动条移动永久置顶
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<div class="ccc">CCC</div>
<div class="ddd">DDD</div>
</body>
</html>
在IE和Firefox中实现层透明的CSS代码 css
在IE和Firefox中实现层透明的CSS代码

<style>
.aa{
	background-color:#000;
	height:50px;
	margin-top:100px;
	color:#ccc;

	filter:alpha(opacity=50); /* IE */
	-moz-opacity:0.5; /* Moz FF */
	opacity: 0.5; /* 支持CSS3的浏览器(FF 1.5也支持)*/
}
</style>
<div style="background-image:url(images/aa.png);width:340px; height:150px;">
	<div class="aa">透明背景</div>
</div>
Struts2使用拦截器完成权限控制示例 struts2
Struts2使用拦截器完成权限控制示例
关键字: struts2 权限控制
示例需求:
   要求用户登录,且必须为指定用户名才可以查看系统中某个视图资源;否则,系统直接转入登陆页面。

一、页面部分
1、登陆页面代码(login.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="loginPage" /></title>  
        </head>  
        <body>  
            <!-- 使用form标签生成表单元素 -->  
            <s:form action="login">  
               <s:textfield name="username" label="%{getText('user')}" />  
               <s:textfield name="password" label="%{getText('pass')}" />  
               <s:submit value="%{getText('login')}" />  
           </s:form>  
       </body>  
   </html>  

 

2、登陆成功页面(welcome.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="succPage" /></title>  
            <s:head />  
        </head>  
        <body>  
            <s:text name="succTip" />  
           <br />  
           <!-- 欢迎,${sessionScope.user},您已经登录!  
           ${sessionScope.pass}-->  
           <p />  
           <s:a href="show.action">show</s:a>  
           <p />  
           <s:a href="add.action">add</s:a>  
           <p />  
           <s:a href="qurey.action">qurey</s:a>  
       </body>  
   </html>  


 

3、登陆失败页面(error.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="errorPage" /></title>  
        </head>  
        <body>  
            <s:text name="failTip" />  
            <p />  
           <s:a href="login.jsp">return</s:a>  
       </body>  
   </html>  


 

4、和权限有关的几个显示页面
(add.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="addPage"/></title>  
        </head>  
        <body>  
            <s:text name="addTip"/>  
            <p />  
           <s:a href="login.jsp">return login</s:a>  
       </body>  
   </html>  


 

(show.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="showPage"/></title>  
        </head>  
        <body>  
            <s:text name="showTip"/>  
            <p />  
           <s:a href="login.jsp">return login</s:a>  
       </body>  
   </html>  


 

(qurey.jsp)
Java代码

    <%@ page language="java" contentType="text/html; charset=GBK"%>  
    <%@taglib prefix="s" uri="/struts-tags"%>  
    <html>  
        <head>  
            <title><s:text name="qureyPage"/></title>  
        </head>  
        <body>  
            <s:text name="qureyTip"/>  
            <p />  
           <s:a href="login.jsp">return login</s:a>  
       </body>  
   </html>  

<
 

二、Action部分(LoginAction.java)
Java代码

    public class LoginAction extends ActionSupport {  
        private static final long serialVersionUID = 1030294046920869257L;  
        private String username;  
        private String password;  
      
        // 处理用户请求的execute方法  
        public String execute() throws Exception {  
            if (isInvalid(getUsername()))  
                return INPUT;  
     
           if (isInvalid(getPassword()))  
               return INPUT;  
     
           if ((getUsername().equals("mm") || getUsername().equals("aumy"))  
                   && getPassword().equals("111")) {  
               // 通过ActionContext对象访问Web应用的Session  
               ActionContext.getContext().getSession().put("user", getUsername());  
               ActionContext.getContext().getSession().put("pass", getPassword());  
               System.out.println(getUsername() + "----" + getPassword());  
               return SUCCESS;  
           } else {  
               System.out.println(getUsername() + "----" + getPassword());  
               return ERROR;  
           }  
       }  
     
       private boolean isInvalid(String value) {  
           return (value == null || value.length() == 0);  
       }  
     
       public String add() {  
           return SUCCESS;  
       }  
     
       public String show() {  
           return SUCCESS;  
       }  
     
       public String qurey() {  
           return SUCCESS;  
       }  
     
       public String getUsername() {  
           return username;  
       }  
     
       public void setUsername(String username) {  
           this.username = username;  
       }  
     
       public String getPassword() {  
           return password;  
       }  
     
       public void setPassword(String password) {  
           this.password = password;  
       }  
   }  

 

三、拦截器部分(AuthorityInterceptor.java)
Java代码

    public class AuthorityInterceptor extends AbstractInterceptor {  
        private static final long serialVersionUID = 1358600090729208361L;  
      
        //拦截Action处理的拦截方法  
        public String intercept(ActionInvocation invocation) throws Exception {  
            // 取得请求相关的ActionContext实例  
            ActionContext ctx=invocation.getInvocationContext();  
            Map session=ctx.getSession();  
            //取出名为user的session属性  
           String user=(String)session.get("user");  
           //如果没有登陆,或者登陆所有的用户名不是aumy,都返回重新登陆  
           if(user!=null && user.equals("aumy")){  
               return invocation.invoke();  
           }  
           //没有登陆,将服务器提示设置成一个HttpServletRequest属性  
           ctx.put("tip","您还没有登录,请登陆系统");  
           return Action.LOGIN;          
       }  
   }  


 

四、配置文件部分
(struts.xml)
Java代码

    <!DOCTYPE struts PUBLIC  
            "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
            "http://struts.apache.org/dtds/struts-2.0.dtd">   
    <struts>   
        <include file="struts-default.xml"/>  
        <!--不受权限控制的Action请求配置-->  
        <package name="non-authority" extends="struts-default" >        
            <action name="login" class="com.aumy.struts.example.LoginAction">  
                <result name="input">/login.jsp</result>  
               <result name="error">/error.jsp</result>  
               <result name="success">/welcome.jsp</result>  
           </action>       
           <action name="qurey" class="com.aumy.struts.example.LoginAction" method="qurey">  
               <result name="success">/qurey.jsp</result>  
           </action>  
     
       </package>  
         
       <!--受权限控制的Action请求配置-->  
       <package name="authority" extends="struts-default">  
           <interceptors>  
               <!--定义一个名为authority的拦截器-->  
               <interceptor  
                   class="com.aumy.struts.example.intercepter.AuthorityInterceptor"  
                   name="authority"/>  
               <!--定义一个包含权限检查的拦截器栈-->  
               <interceptor-stack name="mydefault">  
                   <!--配置内建默认拦截器-->  
                   <interceptor-ref name="defaultStack"/>  
                   <!--配置自定义的拦截器-->  
                   <interceptor-ref name="authority"/>  
               </interceptor-stack>  
           </interceptors>  
             
           <default-interceptor-ref name="mydefault" />  
           <!--定义全局Result-->  
           <global-results>  
               <result name="login">/login.jsp</result>  
           </global-results>  
             
           <action name="show" class="com.aumy.struts.example.LoginAction"  
               method="show">  
               <result name="success">/show.jsp</result>  
           </action>  
             
           <action name="add" class="com.aumy.struts.example.LoginAction"  
               method="add">  
               <result name="success">/add.jsp</result>  
           </action>  
             
       </package>  
   </struts>  



 

(struts.properties)
Java代码

   struts.custom.i18n.resources=message.messageResouce  


 

(web.xml)
Java代码

    <?xml version="1.0" encoding="UTF-8"?>  
    <web-app version="2.4"   
        xmlns="http://java.sun.com/xml/ns/j2ee"   
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
        <display-name>Struts test</display-name>  
      
        <filter>  
           <filter-name>struts2</filter-name>  
           <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
       </filter>  
     
       <filter-mapping>  
           <filter-name>struts2</filter-name>  
           <url-pattern>/*</url-pattern>  
       </filter-mapping>  
     
     
       <welcome-file-list>  
           <welcome-file>login.jsp</welcome-file>  
       </welcome-file-list>  
   </web-app>  


五、国际化资源文件(messageResouce.properties)
Java代码

    loginPage=Login Page  
    errorPage=Error Page  
    succPage=Welcome Page  
    failTip=Sorry,You can't log in!  
    succTip=welcome,you has logged in!   
    user=User Name  
    pass=User Pass  
    login=Login  
    showPage=Show Page  
    showTip=show a example!  
    addPage=Add Page  
    addTip=add a example!  
    qureyPage=Qurey Page  
    qureyTip=qurey a example!
CSS容器内容超出(溢出)自动换行 css
完美支持IE,Firefox,Opera等浏览器。 
<style type="text/css"> 
.linebr { 
   clear: both; /* 清除左右浮动 */  
   width: 100px; /* 必须定义宽度 */  
   word-break: break-word; /* 文本行的任意字内断开 */  
   word-wrap: break-word; /* IE */  
   white-space: -moz-pre-wrap; /* Mozilla */ 
   white-space: -hp-pre-wrap; /* HP printers */ 
   white-space: -o-pre-wrap; /* Opera 7 */ 
   white-space: -pre-wrap; /* Opera 4-6 */ 
   white-space: pre; /* CSS2 */ 
   white-space: pre-wrap; /* CSS 2.1 */ 
   white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */ 
} 
</style> 
<div class="linebr">ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss</div>
Global site tag (gtag.js) - Google Analytics