package org.whatisjava.dang.util;
/*
* StringUtils.java
*
* Created on 2005��12��29��, ����1:02
*/
import java.io.UnsupportedEncodingException;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.regex.*;
// Referenced classes of package net.lybbs.util:
// Constants
public class StringUtils
{
private static Log log;
public static final String EN = "ISO-8859-1";
public static final String CN = "GBK";
public StringUtils()
{
}
public static String ISO2GB(String isoStr)
throws UnsupportedEncodingException
{
return new String(isoStr.getBytes("ISO-8859-1"), "GBK");
}
public static String GB2ISO(String gbStr)
throws UnsupportedEncodingException
{
return new String(gbStr.getBytes("GBK"), "ISO-8859-1");
}
public static String getIP(HttpServletRequest request)
{
String ip = request.getRemoteAddr();
return ip != null ? ip : "";
}
public static String replaceChar(String source, char oldChar, char newChar)
{
if(source == null)
{
return "";
} else
{
return source.replace(oldChar, newChar);
}
}
public static String replaceString(String source, String oldString, String newString)
{
if(source == null || oldString == null || newString == null)
{
return "";
} else
{
return replace(source, oldString, newString);
}
}
public static String[] split(String source, String regex)
{
if(source == null || source.equals(""))
{
return new String[0];
} else
{
return source.split(regex);
}
}
private static String replace(String source, String oldString, String newString)
{
StringBuffer output = new StringBuffer();
int lengthOfSource = source.length();
int lengthOfOld = oldString.length();
int posStart;
int pos;
for(posStart = 0; (pos = source.indexOf(oldString, posStart)) >= 0; posStart = pos + lengthOfOld)
{
output.append(source.substring(posStart, pos));
output.append(newString);
}
if(posStart < lengthOfSource)
{
output.append(source.substring(posStart));
}
return output.toString();
}
public static String toQuoteMark(String str)
{
str = replaceString(str, "'", "'");
str = replaceString(str, "\"", """);
str = replace(str, "\\", "\");
str = replaceString(str, "\r\n", "\n");
str = replaceString(str, "\\n", "\n");
return str;
}
public static String toHtml(String str)
{
str = replaceString(str, "<", "<");
str = replaceString(str, ">", ">");
return str;
}
public static String toBR(String str)
{
str = replaceString(str, "\\n", "\n");
str = replaceString(str, "\n", "<br>\n");
str = replaceString(str, " ", " ");
return str;
}
public static String toSQL(String str)
{
str = replaceString(str, "\r\n", "\n");
return str;
}
public static String htmlFilter(String str){
StringBuffer stringbuffer = new StringBuffer();
for(int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
switch(c)
{
case 39: // '\''
stringbuffer.append("'");
break;
case 34: // '"'
stringbuffer.append(""");
break;
case 60: // '<'
stringbuffer.append("<");
break;
case 62: // '>'
stringbuffer.append(">");
break;
case 38: // '&'
stringbuffer.append("&");
break;
case 32: // ' '
stringbuffer.append(" ");
break;
case 10: // '\n'
stringbuffer.append("<br>");
break;
default:
stringbuffer.append(c);
break;
}
}
return stringbuffer.toString();
}
public static String base64Encode(String str)
{
if(str != null && str.length() > 0)
{
str = new String((new Base64()).encode(str.getBytes()));
}
return str;
}
public static String base64Decode(String str)
{
if(str != null && str.length() > 0)
{
byte buf[] = (new Base64()).decode(str.getBytes());
str = new String(buf);
}
return str;
}
public static String base64Encode(byte str[])
{
String encodeStr = "";
if(str != null && str.length > 0)
{
encodeStr = new String((new Base64()).encode(str));
}
return encodeStr;
}
public static byte[] base64DecodeForByte(String str)
{
byte buf[] = (byte[])null;
if(str != null && str.length() > 0)
{
buf = (new Base64()).decode(str.getBytes());
}
return buf;
}
public static String getRandomNumber(int bits, int to)
{
StringBuffer randBuffer = new StringBuffer();
Random RANDOM = new Random();
for(int i = 1; i <= bits; i++)
{
randBuffer.append(RANDOM.nextInt(to));
}
return randBuffer.toString();
}
public static String urlEncode(String str)
throws EncoderException
{
URLCodec URLCODEC = new URLCodec("UTF-8");
return URLCODEC.encode(str);
}
public static String urlDecode(String str)
throws DecoderException
{
return str;
}
public static String getSQL(String sql, boolean hasOffset, int from, int to)
{
return getMysqlSQL(sql, hasOffset);
}
public static String getMysqlSQL(String sql, boolean hasOffset)
{
StringBuffer sb = new StringBuffer(sql.length() + 20);
sb.append(sql).append(hasOffset ? " limit ?, ?" : " limit ?");
return sb.toString();
}
public static String getDb2SQL(String sql, boolean hasOffset)
{
StringBuffer sb = new StringBuffer(sql.length() + 100);
return sb.toString();
}
public static String getOracleSQL(String sql, boolean hasOffset)
{
StringBuffer sb = new StringBuffer(sql.length() + 100);
return sb.toString();
}
public static String getMssqlSQL(String sql, boolean hasOffset, int from, int to)
{
StringBuffer sb = new StringBuffer(sql.length() + 100);
return sb.toString();
}
private static String getRowNumber(String sql)
{
StringBuffer rownumber = new StringBuffer(50);
return rownumber.toString();
}
private static int getAfterSelectInsertPoint(String sql)
{
int selectIndex = sql.indexOf("select");
return selectIndex + 6;
}
public static String getTopic(String str,int max){
String tempStr=null;
tempStr=str;
if(tempStr.length()>max){
tempStr=tempStr.substring(0,max)+"...";
return tempStr;
}
else{
return tempStr;
}
}
public static String removeHtml(String str){
String tempStr=null;
tempStr=str;
Pattern pattern = Pattern.compile("<.+?>");
Matcher matcher = pattern.matcher(str);
if(matcher.find()){
tempStr=matcher.replaceAll("");
没有合适的资源?快使用搜索试试~ 我知道了~
仿当当网mvc架构设计
共706个文件
gif:269个
java:90个
class:89个
需积分: 9 77 下载量 23 浏览量
2009-05-12
20:12:16
上传
评论
收藏 9.38MB RAR 举报
温馨提示
技术实现:Struts1.2 + Hibernate3.1+JavaScript+AJax 开发环境:Linux + Tomcat + MySQL + MyEclipse 项目描述:主要实现网上购物系统功能模块:用户登录 注册、商品显示、购物车、订单处理等。 具体描述:独立完成项目的各个开发模块,本系统采用了典型MVC的三层架构,利用jsp实现表现层,struts实现业务逻辑,hibernate作数据持久化处理。利用hibernate的事务逻辑线程session实现事务的统一处理。Jsp只负责显示给用户静态的页面,不作业务上的处理。
资源推荐
资源详情
资源评论
收起资源包目录
仿当当网mvc架构设计 (706个子文件)
OrderAction.class 9KB
StringUtils.class 8KB
CartService.class 7KB
OrderService.class 6KB
CatalogService.class 6KB
CommentService.class 6KB
ShopCartAction.class 5KB
RegisterAction.class 5KB
BookImp.class 5KB
DateUtil.class 5KB
Order.class 4KB
AllCategoryImp.class 4KB
RandomServlet.class 4KB
CommentImp.class 4KB
UserImp.class 4KB
DurationFormater.class 4KB
UserService.class 4KB
AddressImp.class 3KB
ProductImp.class 3KB
RegisterForm.class 3KB
Product.class 3KB
GetDate.class 3KB
TestOrder.class 3KB
BookDetailAction.class 3KB
LoginAction.class 3KB
Book.class 3KB
OrderImp.class 3KB
LongCookie.class 3KB
Comment.class 2KB
AllCategory.class 2KB
OrderForm.class 2KB
CommentAction.class 2KB
Address.class 2KB
User.class 2KB
Item.class 2KB
CommentReplyImp.class 2KB
BookList.class 2KB
RandomAction.class 2KB
LoginInfo.class 2KB
SendWayImp.class 2KB
DaoFactory.class 2KB
CommentReply.class 2KB
UserLoginUtil.class 2KB
AddData.class 2KB
CheckUserNameAction.class 2KB
CategoryAction.class 2KB
CartItem.class 2KB
AllCategoryAction.class 2KB
New.class 2KB
TestInsertAllcategory.class 2KB
SendWay.class 1KB
GetCookie.class 1KB
LogOut.class 1KB
Recommend.class 1KB
TestHibernate.class 1KB
Hot.class 1KB
ShowAction.class 1KB
ShoppingController.class 1KB
ResurcesCountry.class 1KB
Constants.class 1KB
TransactionTemplateHbiIml.class 1KB
ForException.class 1KB
HibUtil.class 1KB
GetTime.class 1KB
Error505.class 1KB
Error404.class 1KB
MD5Util.class 996B
TestDateuu.class 991B
ListDetail.class 988B
LoginForm.class 986B
Main.class 970B
ActionServlet.class 967B
TransactionException.class 780B
TestDate.class 764B
DaoException.class 756B
SelectMode.class 622B
AllCategoryDao.class 605B
UserDao.class 583B
CommentDao.class 576B
TestUUID.class 561B
TransactionTemplateFactory.class 550B
AddressDao.class 535B
BookDao.class 528B
UUIDUtils.class 514B
ProductDao.class 484B
OrderDao.class 433B
CommentReplyDao.class 383B
SendWayDao.class 330B
ITransactionTemplate.class 208B
.classpath 3KB
org.eclipse.wst.jsdt.ui.superType.container 49B
book.css 25KB
second.css 20KB
register_login.css 14KB
book_head090107.css 13KB
login.css 13KB
book1.css 11KB
comm_answer.css 10KB
list.css 10KB
shopping_vehicle.css 9KB
共 706 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
doufh88
- 粉丝: 7
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mmqrcode1714153659780.png
- Screenshot_2024-04-27-06-08-58-486_com.baidu.xin.aiqicha.jpg
- 基于Javaweb+Tomcat+MySQL的大学生公寓管理系统+sql文件.zip
- 实训作业基于javaweb的订单管理系统源码+数据库+实训报告.zip
- 多机调度问题贪心算法基于最小堆和贪心算法求解多机调度问题.zip
- 基于同态加密技术的匿名电子投票系统源码.zip
- Pyqt5项目框架-PyQt项目开发实践
- 基于C通过MQTT的智能农业大棚管理系统(本科毕业设计)
- python+CNN的网络入侵检测算法源码.zip
- js 实现记住密码功能 js.cookie.min.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功