User.java
package test;
public class User { private String id; private String name; private String password; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } pu...
//UserAction.java
package web.struts.actions;
import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.strut...
//计算时针和分针之间的夹角import java.lang.Math;public class ClockAngle { public static void main(String[] args) { final String time="12:37";//此处可任意填写时间 int index=time.indexOf(":");//找到:的位置 if(index==-1)return;//如果不存在:则直接退出 String strHour=time.substring(0,index);//截取小时数-字符串型 String strMinute=time.substr...
//首先要下载dom4j.jar//示例1package dom4jdemo;import java.io.File;import java.io.FileInputStream;import java.io.StringBufferInputStream;import java.util.List;
import org.dom4j.Document;import org.dom4j.Element;import org.dom4j.Node;import org.dom4j.io.SAXReader;public class Dom4jParseDemo {
public st...
<c:forEach var="msgList" items="${msgList}"> <tr><td align="center" width="9%" ><input type="checkbox" name="chk" value="<c:out value="${msgList.messageId}"></c:out>"></td> <td width="12%"><c:out value="${msgList.userName}"></c:out></td><!--获取第2列值(即userName)--> <td width="12%"><c:out value="${...
//示例1
import java.util.Date;import java.util.Calendar;public class DateDemo {/** *获取当前时间 */ public static void main(String[] args) { System.out.println("今天最早时刻 = "+getBeginTime()); System.out.println("今天最晚时刻 = "+getEndTime()); } public static Date getBeginTime() { Calendar rightNow=Calen...
import java.util.*;public class Check {
public static void main(String[] args) { String code="420682840424253"; if(!checkFormat(code))//如果其中含有字母则返回 return; String six=code.substring(0,6); code=code.replaceFirst(six,six+"19");//得到17位 char[] arr=code.toCharArray(); int[] arrNumber=new in...
//示例1
import java.lang.Thread;import java.lang.InterruptedException;
class Test1 extends Thread{ public void run(){ try{ for(int i=0;i<10;i++){ System.out.println("正在做第1件事情。。。。"); this.sleep(500); } System.out.println("1.....Over.**************************"); } catch(Interrupte...
public class FormatString{ private static String format(String str) { try { byte[] bytes=str.getBytes("ISO8859_1"); return new String(bytes); } catch(Exception e) { return ""; } } public static void main(String args[]) { ...
//示例1,file基本操作
import java.io.File;import java.io.IOException;class FileDemo{ public static void main(String args[]){ try{ File file=new File("file1.txt"); System.out.println("文件是否存在: "+file.exists()); System.out.println("是文件吗: "+file.isFile()); System.out.println("是文件夹吗: "+fil...
ConnectDB.java
package aptech.bbs.dataaccess;/*此Javabean主要实现连接数据库*/import java.sql.*;public class ConnectDB{ protected Connection con = null; //定义Connection对象 protected ResultSet rs = null; //结果集对象rs //protected Statement st = null; //定义Statement对象 protected PreparedStatement pst = nu...
struts-config.xml中的配置
<action-mappings > <action path="/login" input="/login.jsp" type="com.yourcompany.struts.action.LoginAction" />
</action-mappings>
test.jsp
<html:link action="login.do?name=administrator">点我</html:link>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %><%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %><%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %><%@ taglib uri="ht...
<%@ page contentType="text/html; charset=GBK" %><%@ page import="java.util.*"%><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %><%@ taglib uri="/WEB-INF/struts-nested.tld...
实现Filter类的servlet的写法
package filtertest;
import java.io.IOException;import java.io.UnsupportedEncodingException;
import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax...