喵宅苑 MewoGarden × 技术宅社区II | Z站 Z Station 棒棒哒纯文字二次元技术社区

正文

2学术讨论

作者:2学术讨论
{"name":"2学术讨论","sizeType":1,"icon":"","order":9999,"description":"","comp":""}

回复

求高手帮忙简化一段代码

作者:繁华,渲染了谁
如题,我智商捉急,实在想不出神马方法 var col=new Array("#F00","#3C6","#F39","#09F"); function color() { document.getElementById("logo").style.borderTopColor=col[0]; document.getElementById("logo").style.borderRightColor=col[1]; document.getElementById("logo").style.borderBottomColor=col[2]; document.getElementById("logo").style.borderLeftColor=col[3]; setInterval("color1()",500); } function color1() { document.getElementById("logo").style.borderTopColor=col[1]; document.getElementById("logo").style.borderRightColor=col[2]; document.getElementById("logo").style.borderBottomColor=col[3]; document.getElementById("logo").style.borderLeftColor=col[0]; setInterval("color2()",500); } function color2() { document.getElementById("logo").style.borderTopColor=col[2]; document.getElementById("logo").style.borderRightColor=col[3]; document.getElementById("logo").style.borderBottomColor=col[0]; document.getElementById("logo").style.borderLeftColor=col[1]; setInterval("color3()",500); } function color3() { document.getElementById("logo").style.borderTopColor=col[3]; document.getElementById("logo").style.borderRightColor=col[0]; document.getElementById("logo").style.borderBottomColor=col[1]; document.getElementById("logo").style.borderLeftColor=col[2]; setInterval("color()",500); }
查看回复

jsp文件在tomcat里运行找不到自定义包了,该怎么定义才对

作者:胖虎
这个包没写错吧 package Md5; public class Md5 { /** * 将密码转换成MD5加密后的字符串形式. * @param password 原始密码 * @return 32位字符串 */ public static String getMD5(String password) { byte[] source = password.getBytes(); String s = null; char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; try { java.security.MessageDigest md = java.security.MessageDigest .getInstance("MD5"); md.update(source); byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数, // 用字节表示就是 16 个字节 char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符, // 所以表示成 16 进制需要 32 个字符 int k = 0; // 表示转换结果中对应的字符位置 for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节 // 转换成 16 进制字符的转换 byte byte0 = tmp; // 取第 i 个字节 str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, // >>> 为逻辑右移,将符号位一起右移 str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换 } s = new String(str); // 换后的结果转换为字符串 } catch (Exception e) { e.printStackTrace(); } return s; } } 然后,不知道在tomcat里边改怎么放 jsp里边才能找到我写的这个包 这个是jsp <%@ page language="java" import="java.util.*" import = "Md5.*" import="java.sql.*" import = "java.util.Date" pageEncoding="utf-8"%> <% //String path = request.getContextPath(); //String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String emsg = "ertyuio"; java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date currentTime = new java.util.Date();//得到当前系统时间 String t = formatter.format(currentTime); //将日期时间格式化 Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("xxXXXXXXXXXXXXXXX"); Statement stat = conn.createStatement(); String id = request.getParameter("id"); String password = request.getParameter("password"); String password1; String ip = request.getRemoteAddr(); String sql = ""; //password1 = Md5.getMD5(password); int a ; int a1 = 0; int a2 = 0; int i = 0; int a3 = 0; %> <%=id +" "+password+" "+ip+" "+t+" " %> <% sql = "SELECT COUNT(id) FRoM users WHERE id = '"+id+"'" ; ResultSet rs = stat.executeQuery(sql); rs.next(); a = rs.getInt(1); %> <%="数据库中共有 "+a %> <% if(a == 0){ sql = "INSERT INTO users(id,password,creat_time,ip) VALUES(?,?,?,?)"; PreparedStatement ps = conn.prepareStatement(sql); if(id == null ) {a1 = 0;} else if(id.getBytes("UTF-8").length>30) {a1 = 1;} else if(password == null ) {a2 = 0;} else if( password.getBytes("UTF-8").length>900) {a2 = 1;} else if (id != null && password != null && ip != null){ password1 = Md5.getMD5(password); emsg = "1"; ps.setString(1,id); ps.setString(2,password1); ps.setString(3,t); ps.setString(4,ip); i = ps.executeUpdate(); } } else if (a == 1){a3 = 1;} else {a=0;} %> <%="md5加密后 "+password1+" " %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>注册系统 </title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head> <body> <script type = "text/javascript"> function a() //得到文本内容 { id = document.log.id.value; password = document.log.password.value; password1 = document.log.password1.value; //alert(id +" "+password +" "+ password1 ); if( id == ""){ alert("请填写用户名 "); document.log.uid.focus(); } else if(password == ""){ alert("密码不能为空"); document.log.password.focus(); } else if(password1 != password){ alert("请检查密码是否一致"); document.log.password.focus(); } else log.submit(); } if(<%= i%> == "1"){ alert("成功注册"); } if(<%= a1%> == "1"){ alert("ID输入过长"); } if(<%= a2%> == "1"){ alert("留言输入过长"); } </script> <!-- 页面******************************************************************************************** --> <form name = "log" method = "post" > <%=emsg %> <%= "a3 = "+ a3 %> <table> <tr> <td> 用户名:</td><td><input type = "text" name = "id"> </td> </tr> <tr> <td> 设置密码:</td><td> <input type = "password" name = "password"> </td></tr> <tr> <td> 确认密码</td><td><input type = "password" name = "password1"></td></tr> <tr> <td align = "right"> </td><td align = "left">   <input type = "reset" >  <input type = "button" value = "注册"; ></td></tr> </table> </form> </body> </html> 部分细节没完善和重复的先不理,因为不知道怎么用自定义包来md5加密,这个是主要问题
查看回复

老师出了四道js题,我都运行不出答案/(ㄒoㄒ)/~~

作者:月扉琉薰
第一题: <html> <body> <script> price=parseInt(prompt("请输入商品价格",0)); var n; n=parceInt(price/100); switch(n) { case 0:case 1: price=price; break; case 2:case 3:case 4: price=price*0.97; break; case 5:case 6:case 7:case 8:case 9: price=price*0.95; break; default: pricee=price*0.92; } document.write("商品实际销售价格为:"+price); </script> </body> </html> 第二题: <html> <body> <script> var n,i,j,k; for(n=100;n<1000;n++) { i=parseInt(n\100); j=parseInt(n\10-i*10); k=n-j*10-i*100; if (n==i*i*i+j*j*j+k*k*k) document.write(n+"是水仙花数"+"<BR>"); } </script> </body> </html> 第三题: <html> <body> <script> var i,j,k; for(i=0;i<=20;i++) { for(j=0;j<=33;j++) { k=100-i-j; if(i*5+j*3+k*(1/3)=100) { document.write("公鸡的只数为:"+i+"母鸡的只数为:"+j+"小鸡的只数为:"+k+"<BR>") } } } </script> </body> </html> 第四题: <HTML> <BODY> <CENTER> <SCRIPT language="JavaScript"> <!-- var i,j,max; j=1; max=n; for (i=1;i<n;i++) { j=10*n; k=n*j+k; max=max+k; } max=max*2-k; document.write("和="+max); //--> </SCRIPT> </CENTER> </BODY> </HTML> 菜鸟渣渣……求助求助啊……( >﹏<。)~呜呜呜……
查看回复

提问,求回答,有关于Mysql数据库乱码的问题

作者:yangkeao
[mw_shl_code=php,true]<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("chat", $con); $result = mysql_query("SELECT * FROM chat"); while($row = mysql_fetch_array($result)) { echo $row['time'] . " " . $row['neirong']; echo "<br />"; } mysql_close($con); ?>[/mw_shl_code] 输出数据数字和英文没问题,可是中文是??? 该贴已经同步到 yangkeao的微博
查看回复

[Web开发] 求助链接页面字体变大的问题……

作者:风铃_chasing
我在做网页,当点击页面A上的链接到页面B的时候,页面B的字体就变大了,而直接打开B的话字体还是正常的……求大神指点#20x
查看回复

求大大说明一下finally语句的作用及例子

作者:文艺de蛋蛋
#39t本人初学javascript,求大神指点一下try,catch,finally中finally的作用,最好有例子~~~喵~~~无限感激
查看回复

DIV+CSS里 为什么会出现这种情况。。求教

作者:噢!麦嘎
[i=s] 本帖最后由 噢!麦嘎 于 2013-1-30 16:11 编辑 为什么 做一个 <div class="大IDV"> <div class=“小DIV”>在小的DIV里设置与上边距为20(margin-TOP:20px;),为什么整个大的DIV全都下沉,而不是只有这个下沉呢?</div> </div> 召唤高手。。@pocketj @銀琉迦 @百里叮 问题已解决:外边距合并问题,只有普通文档流中块框的垂直外边距才会发生外边距合并。行内框、浮动框或绝对定位之间的外边距不会合并。!108! 刚刚看教程看到了。。哭~
查看回复

为什么我的下拉里没有这个属性?

作者:噢!麦嘎
<a href="http://www.baidu.com" hidefocus="true">为什么我的没有</a> 在网上找了很多 说这个属性是去掉虚线框 但为什么我在后面敲了空格之后,并不出现hidefocus的下拉呢? 之前也没有遇到过链接出来之后带虚线框的情况。。。 !9!!6!!10!!8!!13!!53!!12!!11!!7!
查看回复
上一页
下一页
0%
闽ICP备2022013136号闽公网安备35092202000188号
站点地图友情链接:
喵宅苑
喵空间社区程序
喵宅苑 静态版
络合兔
Lanzainc
技术宅
小五四博客
莉可POI
Mithril.js
枫の主题社
Project1
午后少年
机智库
七濑胡桃
xiuno
幻想の日常
魂研社
Nothentai
0xffff
欲望之花
泽泽社长