ITeye博客

struts2拦截器详解实例

netxdiy · 2011-03-21 16:11 · struts2 · 企业架构 · HTML · Java · Apache · Struts · JSP · Markdown

struts.xml /input.jsp /addOK.jsp /error.jsp input.jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%@taglib uri="/struts-tags" prefix="s" %> My JSP 'test.jsp' starting page

name: age:

InputAction.java package com.bjsxt.action; import com.opensymphony.xwork2.ActionSupport; public class InputAction extends ActionSupport { @Override public String execute() throws Exception { return super.execute(); } } UserAction.java package com.bjsxt.action; import com.opensymphony.xwork2.ActionSupport; public class UserAction extends ActionSupport { private String name; private int age; @Override public String execute() throws Exception { System.out.println("a user added!"); return super.execute(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } addOK.jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> My JSP 'test.jsp' starting page addOK
error.jsp <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> My JSP 'test.jsp' starting page 严禁做重复的事!

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。