<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Ins...
function validate(form) { var username = form.userName.value.trim(); var password = form.passWord.value.trim(); var repassword = form.rePassWord.value.trim(); var birthday = form.birthDay.value.trim(); return true;}function register(form) { if (validate(form)) { ...
function validateDate(date) { var pos1 = date.indexOf("-"); var pos2 = date.indexOf("-", pos1 + 1); if ( pos1 == -1 || pos2 == -1 ) { return false; } var year = date.substr(0, pos1); var month = date.substr(0, pos1); var day = date.substr(0, pos1); if ( month < 1 ...
配置拦截器:
<interceptors> <interceptor name="xxx" class="xxxx"> <param name="参数名">参数值</param> </interceptor></interceptors>定义拦截器栈:
<interceptor-stack name="拦截器栈1"> <interceptor-ref name="拦截器1" /> <interceptor-ref name="拦截器2" /> <interceptor-ref name="拦截器栈2" /></intercepto...
Action:
public String execute() throws Exception { if (this.getUserName().equals("angel") && this.getPassword().equals("123")) { this.setResult(true); return SUCCESS; } else if (this.getUserName().equals("aa")) { throw new SQLException("th...
1. Action类的getter和setter方法不仅可以封装HTTP请求参数,还可以封装处理结果信息。
2. 通过ActionContext访问ServletAPI
取得参数
ActionContext ctx = ActionContext.getContext();Map application = ctx.getApplication();Map session = ctx.getSession();Integer counter = (Integer) application.get("counter");session.put("userName", use...
在使用Struts2 标签前,需要先引入该标签:
<%@ taglib prefix="s" uri="/struts-tags" %>
1. 需要添加的jar包:
Struts2-core.jar
Xwork.jar
Ognl.jar
Freemarker.jar
Commons-logging.jar
2. 在web.xml中的配置:
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-nam...