虽然知道结果仍然心累,加油哦余柳

// 为啥没有每一句都写注释,我不懂啊!不管了写打个一遍再说
/package声明是属于哪个包裹,反正我就当他是文件夹,分类文件夹,别纠结啊,哎呀不行了,脑袋走偏了
package com.lyq.action.interceptor; //有别万了这罪恶的分号,我记得lisp是不需要的,又想起伤心事了,高大上的lisp
import  java.util.Map;
import java.com.action.BaseAction;//因为重复开始不断报错了,我在同一个java类中写,就照着上的打,我估计myeclipse会被我玩坏的
import com.opensymphony.xwork2.*;//全部导入了
public class CustomerLoginInteceptor extends AbstracInterceptor //extends就是继承抽象类,ctrl+ 单击就会跑去他爸爸那里了,在他爸爸那里只要ctrl + t就可以弹出儿子了实现类,不要在意这些细节
{
private static final long serialVersionUID = 1L;
public String intercept(ActionInvocation invocation)throw Exception //不行了听着浮夸,我要浮夸起来了,当你要夏斯里地就听陈奕迅的浮夸吧
{
ActionContext context = invocatio.getInvocationContext();
Map<String ,Object> session context.getSession();
if(session.get("customer")!=null){
return invocation.invoke();
}
return BaseAction.CUSTONMEER_LOGIN;

}

}


ApplicationContextAware 接口的作用
加载spring配置文件时,如何spring配置文件中所定义的bean类实现了applicationContextAware 接口,那么在加载spring配置文件时,会自动
调用applicationContextAware接口中的
public void setApplicationContext(ApplicationContext context)
throws BeanException 方法,获得ApplicationContext对象

前提必须在Spring配置文件中只当该类
如:
真特么受不了,为啥表达的如此难懂,要是能转成动画就好了
public class ApplicationContextRegister implements ApplicationContextAware{

private Log log = LogFactory.getLog(getClass());
public void setApplicationContext(Application applicationContext)
{
ContextUtils.setApplicationContext(application);
log.debug("ApplicationContext registed");
}

所有的bean-public.xml
所有的模块公用配置
1.数据源配置
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboP">

</bean>
2.spring 对sessionFactory创建支持
3.事务管理
4.事物通知
5.aop配置
眼看已经是早上9:34 ,我才打了52行,看来今天要挂啦
我心里默默算了一下,每一秒打一句代码,一个小时3600秒,我要3个小时,才能打完10000行代码
jquery
window.onload = function()
{
document.getElementById("btn").onclick = function();
{

};
}
照着打代码发现还是木有太大的进步,但是得坚持,简单的事,重复做,坚持做,就会变得伟大
定个目标吧!写个模仿着写个注册,登录功能,注销功能

十一月 20, 2015 3:05:51 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor

查了一下是applicationContext.xml少了dataSource的配置我加了上去
<!-- dataSource config -->

    <bean id ="dataSource" class ="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.gjt.mm.mysql.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/" />
        <property name="username" value="root" />
        <property name="password" value=""/>
    </bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

<property name="dataSource">
<ref bean="dataSource"/>

</property>
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
本来我在hibernate中就已经连接了数据库,现在又在spring配置文件连接数据库,这玩意有点问题,不过没有关系,先往下打再说
现在才打了多少92行,我的10000行啊
JQuery中$.ajax()方法参数详解 (2010-08-02 15:26:36)转载▼
标签: jquery ajax each it 分类: JQuery
url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址。
type: 要求为String类型的参数,请求方式(post或get)默认为get。注意其他http请求方法,例如put和
      delete也可以使用,但仅部分浏览器支持。
timeout: 要求为Number类型的参数,设置请求超时时间(毫秒)。此设置将覆盖$.ajaxSetup()方法的全局设
         置。
async:要求为Boolean类型的参数,默认设置为true,所有请求均为异步请求。
       如果需要发送同步请求,请将此选项设置为false。注意,同步请求将锁住浏览器,用户其他操作必须等
       待请求完成才可以执行。
cache:要求为Boolean类型的参数,默认为true(当dataType为script时,默认为false)。
       设置为false将不会从浏览器缓存中加载请求信息。
data: 要求为Object或String类型的参数,发送到服务器的数据。如果已经不是字符串,将自动转换为字符串格
      式。get请求中将附加在url后。防止这种自动转换,可以查看processData选项。对象必须为key/value格
      式,例如{foo1:"bar1",foo2:"bar2"}转换为&foo1=bar1&foo2=bar2。如果是数组,JQuery将自动为不同
      值对应同一个名称。例如{foo:["bar1","bar2"]}转换为&foo=bar1&foo=bar2。
dataType: 要求为String类型的参数,预期服务器返回的数据类型。如果不指定,JQuery将自动根据http包mime
          信息返回responseXML或responseText,并作为回调函数参数传递。
          可用的类型如下:
          xml:返回XML文档,可用JQuery处理。
          html:返回纯文本HTML信息;包含的script标签会在插入DOM时执行。
          script:返回纯文本JavaScript代码。不会自动缓存结果。除非设置了cache参数。注意在远程请求
                  时(不在同一个域下),所有post请求都将转为get请求。
          json:返回JSON数据。
          jsonp:JSONP格式。使用SONP形式调用函数时,例如myurl?callback=?,JQuery将自动替换后一个
                “?”为正确的函数名,以执行回调函数。
          text:返回纯文本字符串。
beforeSend:要求为Function类型的参数,发送请求前可以修改XMLHttpRequest对象的函数,例如添加自定义
            HTTP头。在beforeSend中如果返回false可以取消本次ajax请求。XMLHttpRequest对象是惟一的参
            数。
            function(XMLHttpRequest){
               this;   //调用本次ajax请求时传递的options参数
            }
complete:要求为Function类型的参数,请求完成后调用的回调函数(请求成功或失败时均调用)。
          参数:XMLHttpRequest对象和一个描述成功请求类型的字符串。
          function(XMLHttpRequest, textStatus){
             this;    //调用本次ajax请求时传递的options参数
          }
success:要求为Function类型的参数,请求成功后调用的回调函数,有两个参数。
         (1)由服务器返回,并根据dataType参数进行处理后的数据。
         (2)描述状态的字符串。
         function(data, textStatus){
            //data可能是xmlDoc、jsonObj、html、text等等
            this;  //调用本次ajax请求时传递的options参数
error:要求为Function类型的参数,请求失败时被调用的函数。该函数有3个参数,即XMLHttpRequest对象、错
       误信息、捕获的错误对象(可选)。
       ajax事件函数如下:
       function(XMLHttpRequest, textStatus, errorThrown){
          //通常情况下textStatus和errorThrown只有其中一个包含信息
          this;   //调用本次ajax请求时传递的options参数
       }
contentType:要求为String类型的参数,当发送信息至服务器时,内容编码类型默认
             为"application/x-www-form-urlencoded"。该默认值适合大多数应用场合。
dataFilter:要求为Function类型的参数,给Ajax返回的原始数据进行预处理的函数。
            提供data和type两个参数。data是Ajax返回的原始数据,type是调用jQuery.ajax时提供的
            dataType参数。函数返回的值将由jQuery进一步处理。
            function(data, type){
                //返回处理后的数据
                return data;
            }
global:要求为Boolean类型的参数,默认为true。表示是否触发全局ajax事件。设置为false将不会触发全局
        ajax事件,ajaxStart或ajaxStop可用于控制各种ajax事件。
ifModified:要求为Boolean类型的参数,默认为false。仅在服务器数据改变时获取新数据。
            服务器数据改变判断的依据是Last-Modified头信息。默认值是false,即忽略头信息。
jsonp:要求为String类型的参数,在一个jsonp请求中重写回调函数的名字。
       该值用来替代在"callback=?"这种GET或POST请求中URL参数里的"callback"部分,例如
       {jsonp:'onJsonPLoad'}会导致将"onJsonPLoad=?"传给服务器。
username:要求为String类型的参数,用于响应HTTP访问认证请求的用户名。
password:要求为String类型的参数,用于响应HTTP访问认证请求的密码。
processData:要求为Boolean类型的参数,默认为true。默认情况下,发送的数据将被转换为对象(从技术角度
             来讲并非字符串)以配合默认内容类型"application/x-www-form-urlencoded"。如果要发送DOM
             树信息或者其他不希望转换的信息,请设置为false。
scriptCharset:要求为String类型的参数,只有当请求时dataType为"jsonp"或者"script",并且type是GET时
               才会用于强制修改字符集(charset)。通常在本地和远程的内容编码不同时使用。

案例代码:
$(function(){
    $('#send').click(function(){
         $.ajax({
             type: "GET",
             url: "test.json",
             data: {username:$("#username").val(), content:$("#content").val()},
             dataType: "json",
             success: function(data){
                         $('#resText').empty();   //清空resText里面的所有内容
                         var html = '';
                         $.each(data, function(commentIndex, comment){
                               html += '<div class="comment"><h6>' + comment['username']
                                         + ':</h6><p class="para"' + comment['content']
                                         + '</p></div>';
                         });
                         $('#resText').html(html);
                      }
         });
    });
});

顺便说一下$.each()函数:
$.each()函数不同于JQuery对象的each()方法,它是一个全局函数,不操作JQuery对象,而是以一个数组或者对象作为第1个参数,以一个回调函数作为第2个参数。回调函数拥有两个参数:第1个为对象的成员或数组的索引,第2个为对应变量或内容。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="text注册" />
<meta name="description" content="text注册" />
<meta name="renderer" content="webkit" />
<title>注册 - texttext</title>

<link rel="stylesheet" href="http://static.text.me/resources/text/css/style.css" type="text/css" />
<script src="http://static.text.me/resources/text/js/jquery-1.8.0.js" type="text/javascript"></script>
<!-- <script src="http://static.text.me/resources/text/js/common.js" type="text/javascript"></script> -->
<!-- <script src="http://static.text.me/resources/text/js/utils.js" type="text/javascript"></script> -->
<script src="http://static.text.me/resources/text/js/jquery.validate.js" type="text/javascript"></script>
<script src="http://static.text.me/resources/text/js/pswd/jsbn.js" type="text/javascript"></script>
<script src="http://static.text.me/resources/text/js/pswd/prng4.js" type="text/javascript"></script>
<!-- <script src="http://static.text.me/resources/text/js/pswd/rng.js" type="text/javascript"></script> -->
<!-- <script src="http://static.text.me/resources/text/js/pswd/rsa.js" type="text/javascript"></script> -->
<!-- <script src="http://static.text.me/resources/text/js/pswd/base64.js" type="text/javascript"></script> -->
</head>

<body class="body_home">
<div class="lr_min_height">
<div class="Regest_bg">
<div class="div_Regest"><a href="/"><img src="http://static.text.me/resources/text/images/logo_login.png"/></a></div>
</div>
<div class="login_bg" style="height:auto;">
<div class="div_login">
    <div class="div_login_title"><h1>注册text帐号</h1></div>
    <form id="registerForm" action="/register/submit.jhtml" method="post" class="form_lgoin_box">
        <div class="div_Regest_box">
            <label>邮箱:</label>
                <input class="input_login_txt" type="text" name="email" />
                <label class="tipsa">请输入您常用的邮箱</label>
            </div>
            <div class="div_Regest_box">
            <label>密码:</label>
                <input class="input_login_txt" type="password" name="password" />
                <label class="tipsa">请使用6~20个英文字母(区分大小写)、符号或数字</label>
            </div>
            <div class="div_Regest_box">
            <label>确认密码:</label>
                <input class="input_login_txt" type="password" name="rePassword" />
                <label class="tipsa">请使用6~20个英文字母(区分大小写)、符号或数字</label>
            </div>
            <div class="div_Regest_box" style="margin-top:5px;">
            <label style="height:20px;">&nbsp;</label>
            <input style="float:left; margin-top:4px;" type="checkbox" checked="checked" name="treaty" value="true" />
                <p>我同意并愿意遵守text</p>
                <a target="_blank" href="/help.jhtml#agreement">用户协议和隐私政策</a>
                <label class="tipsa" style="line-height: 21px;"></label>
            </div>
            <div class="div_Regest_box">
            <label>&nbsp;</label>
            <input class="btn_login_regest" type="submit" value="立即注册"><br>
                <label style="clear:both;">&nbsp;</label>
                <label class="tipon">如果你已拥有text帐号,请<a href="/login.jhtml?redirectUrl=%2F" rel="nofollow">在此登录</a></label>
            </div>
<div class="div_Regest_box">
<label>快捷登录:</label>
<a style="padding:8px 0;" href="/qq/login.jhtml?operator=register&redirectUrl=%2F" rel="nofollow"><img alt="QQ登录" width="63" height="24" src="http://static.text.me/resources/text/images/qq_login.png" /></a>
</div>
        </form>
    </div>
</div>
<div class="index_bottom_bg login_bottom_bg">
<div class="index_bottom">
    <p class="p_copy">Copyright © 2014-2015 www.text.com. All Rights Reserved.</p>
    <p class="p_foot_bar"><a target="_blank" href="/common/about.jhtml">关于我们</a></li> - <a target="_blank" href="/common/joinus.jhtml">加入我们</a> - <a target="_blank" href="/common/contact.jhtml">联系我们</a> - <a target="_blank" href="/help.jhtml">帮助中心</a></p>
    </div>
</div>
<!-- <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?f2a5f48af9d935f4001ca4c8850ce7c0";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script> --></div>
<script type="text/javascript">
$(document).ready(function() {
// 表单验证
$("#registerForm").validate({
//一条规则对应下面的一个message
rules: {
email: {
required: true,
pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
//默认缓存是false,通过发送email到这个url,返回一个true就通过,否则为false无法通过
remote: {
url: "/register/check_email.jhtml",
cache: false
}
},
password: {
required: true,
pattern: /^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~]{6,20}$/
},
rePassword: {
required: true,
equalTo: "input[name='password']"
},
treaty: {
required: true
}
},
//对应上面的rules
messages: {
email: {
required: "注册邮箱必填",
pattern: "请输入正确的邮箱地址",
remote: "邮箱被禁用或已被注册"
},
password: {
required: "登录密码必填",
pattern: "请使用6~20个英文字母(区分大小写)、符号或数字"
},
rePassword: {
required: "请重复输入密码",
equalTo: "两次密码不一致"
},
treaty: {
required: "请勾选用户协议"
}
},
errorPlacement: function(error, element) {
element.nextAll("label.tipsa").css("color", "#ff6000").text(error.text());
},
success: function(e) {
        },
submitHandler: function(form) {
$.ajax({
//发送请求的url
url: "/common/public_key.jhtml",
//发送请求的类型有get和post等
type: "GET",
//发送数据的类型json
dataType: "json",
//cache:要求为Boolean类型的参数,默认为true(当dataType为script时,默认为false)。
                //   设置为false将不会从浏览器缓存中加载请求信息。
cache: false,
//避免这种现象,在$.ajax请求中的beforeSend方法中把提交按钮禁用掉,等到Ajax请求执行完毕,在恢复按钮的可用状态。
beforeSend: function() {
$(":submit").prop("disabled", true);
},
success: function(data) {
var rsaKey = new RSAKey();
rsaKey.setPublic(b64tohex(data.modulus), b64tohex(data.exponent));
var enPassword = hex2b64(rsaKey.encrypt($("input[name='password']").val()));
$.ajax({
url: $("#registerForm").attr("action"),
type: "POST",
data: {

email: $("input[name='email']").val(),
enPassword: enPassword
},
dataType: "json",
cache: false,
success: function(message) {
if (message.type == "success") {
$(":submit").prop("disabled", false);
try {
if(window.opener)
window.opener.loginMsg();
} catch (e) {
console.log("不同域==========" + e);
}
var loaded = 0;
var synarr = $(message.content);
if(message.content != "" && synarr && synarr.length != 0) {
synarr.each(function(index, ele) {
    $.getScript(ele.src, function(){
        if (++loaded == synarr.length) {
location.href = "/register/success.jhtml";
        }
    });
});
} else {
location.href = "/register/success.jhtml";
}
} else {
alert(message.content);
$(":submit").prop("disabled", false);
}
}
});
}
});
}
});
if($(window).height() > 820) {
$(".login_bottom_bg").css({"position":"fixed"});
}
});
</script>
</body>
</html>

猜你喜欢

转载自a1245096366.iteye.com/blog/2258209
今日推荐