📄 tagutil.java
字号:
package com.easyjf.util;
import java.util.List;
import com.easyjf.beans.BeanWrapper;
/**
* 用于生成并处理各种各样标签的工具类
* @author 大峡
*
*/
public class TagUtil {
private static TagUtil singleton=new TagUtil();
public static TagUtil getInstance()
{
return singleton;
}
/**
* 显示页码
*
* @param currentPage
* @param pages
* @return 分布htmp字符串
*/
public static String showPageHtml(int currentPage, int pages) {
String s = "";
if (currentPage > 1) {
s += "<a href=# onclick='return gotoPage(1)'>首页</a> ";
s += "<a href=# onclick='return gotoPage(" + (currentPage - 1)
+ ")'>上一页</a> ";
}
int beginPage = currentPage - 3 < 1 ? 1 : currentPage - 3;
if (beginPage < pages) {
s += "第 ";
for (int i = beginPage, j = 0; i <= pages && j < 6; i++, j++) {
if (i == currentPage)
s += "<font color=red>" + i + "</font> ";
else
s += "<a href=# onclick='return gotoPage(" + i + ")'>" + i
+ "</a> ";
}
s += "页 ";
}
if (currentPage < pages) {
s += "<a href=# onclick='return gotoPage(" + (currentPage + 1)
+ ")'>下一页</a> ";
s += "<a href=# onclick='return gotoPage(" + pages + ")'>末页</a> ";
}
// s+=" 转到<input type=text size=2>页";
return s;
}
public static String showPublishPageHtml(String path, int currentPage,
int pages) {
String s = "";
boolean isDir = false;
if (path.endsWith("/"))
isDir = true;
if (currentPage > 1) {
s += "<a href=" + path + (isDir ? "1" : "") + ".htm>首页</a> ";
s += "<a href=" + path
+ (currentPage - 1 > 1 ? (currentPage - 1) + "" : "")
+ ".htm>上一页</a> ";
}
int beginPage = currentPage - 3 < 1 ? 1 : currentPage - 3;
if (beginPage < pages) {
s += "第 ";
for (int i = beginPage, j = 0; i <= pages && j < 6; i++, j++) {
if (i == currentPage)
s += "<font color=red>" + i + "</font> ";
else
s += "<a href=" + path
+ (i > 1 ? i + "" : (isDir ? i + "" : ""))
+ ".htm>" + i + "</a> ";
}
s += "页 ";
}
if (currentPage < pages) {
s += "<a href=" + path + (currentPage + 1) + ".htm>下一页</a> ";
s += "<a href=" + path + pages + ".htm>末页</a> ";
}
// s+=" 转到<input type=text size=2>页";
return s;
}
public static String options(List list,String valuePoperty,String titlePoperty,String value)
{
if(list==null)return "";
String[][] items=new String[list.size()][2];
for(int i=0;i<list.size();i++)
{
BeanWrapper wrapper=new BeanWrapper(list.get(i));
items[i][0]=wrapper.getPropertyValue(valuePoperty).toString();
items[i][1]=wrapper.getPropertyValue(titlePoperty).toString();
}
return options(items,value);
}
public static String options(String[][] items, String value) {
String s = "";
for (int i = 0; i < items.length; i++) {
s += "<option value='" + items[i][0] + "' "
+ (items[i][0].equals(value) ? "selected" : "") + ">"
+ items[i][1] + "</option>";
}
return s;
}
public static String options(int min, int max, int value) {
String s = "";
for (int i = min; i <= max; i++) {
s += "<option value='" + i + "' " + (i == value ? "selected" : "")
+ ">" + i + "</option>";
}
return s;
}
public static String checkBox(Object value) {
String ret = "";
if (value instanceof Boolean) {
if (((Boolean) value).booleanValue())
ret = "checked";
}
return ret;
}
public static String checkBox(String obj,Object value) {
String ret = "";
if (obj!=null && obj.equals(value)) {
ret = "checked";
}
return ret;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -