日期:2014-05-17  浏览次数:20733 次

jquery放入jsp中失效
请问,我在jsp中添加了jquery代码,运行后jquery失效,但是如果把jsp改成html后却正常执行,这是怎么回事啊,谢谢啦。
我是用myeclipse做得,在mozilla中预览时可以看到效果,可是在IE中却不行。
这是我的代码:
<%@ page contentType="text/html;charset=gb2312" pageEncoding="GB2312"%>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%>
<%@ page isELIgnored="false" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<link href="css/complete_form.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  $('#signup').validate({
  rules: {
  email: {
  required: true,
  email: true
  },
  password: {
  required: true,
  rangelength:[8,16]
  },
  password2: {equalTo:'#password'},
phone:{
required:true,
number:true,
rangelength:[11,11]
},
address:{
required:true
},
  problemAnswer:{
  required:true
  },
trueName:{required:true},
  spam: "required"
  }, //end rules
  messages: {
  email: {
  required: "请输入邮箱地址",
  email: "这不是正确的邮箱地址格式"
  },
  password: {
  required: '请输入一个密码',
  rangelength: '密码必须是8到16位的有效字符'
  },
  password2: {
  equalTo: '两次输入的密码不一致'
  },
phone:{
required:'请输入一个号码',
number:'存在非数字字符',
rangelength:'手机号码不是有效位数'
},
address:{required:'请输入有效地址'
},
problemAnswer:{required:'请输入有效答案'
},
trueName:{required:'请输入有效姓名'
},
  },
  errorPlacement: function(error, element) { 
  if ( element.is(":radio") || element.is(":checkbox")) {
  error.appendTo( element.parent()); 
  } else {
  error.insertAfter(element);
  } 
  } 
  }); // end validate 
}); 
</script>
</head>
<body background="images/login.jpg">
<form action="UserRegister.do?method=register" method="post" name="signup" id="signup">
  <fieldset>
  <div class="title">用户注册</div>
  <div class="fuzhu">注意:带*的为必填项</div>
  </fieldset>
  <fieldset>
<legend class="declare">请输入您的基本信息</legend>
<div>
  <label for="name" class="label">*昵称</label>
  <input name="userName" type="text" class="required" id="name" title="请输入昵称"></input>
  <label class="declare">&nbsp;&nbsp;只能是数字或者英文字母</label>
  </div>
<div>
  <label for="name" class="label">*真实姓名</label>
  <input name="trueName" type=&quo