zoukankan      html  css  js  c++  java
  • Struts2通配符的使用

    • 配置好struts2环境后
    LoginAction
    package com.login.action;
     
    public class LoginAction {
       public String checkLogin() {
          System.out.println("checkLogin");
          return "login";
       }
    }
    LogoutAction
    package com.login.action;
     
    public class LogoutAction {
       public String checkLogout() {
          System.out.println("checkLogout");
          return "logout";
       }
    }
    struts-itcast.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
       "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
       "http://struts.apache.org/dtds/struts-2.3.dtd">
    <struts>
        <package name="struts2_login" namespace="/" extends="struts-default">
            <action name="*_*" class="com.login.action.{1}Action" method="{2}">
                <result name="login">/loginSuc.jsp</result>
                <result name="logout">/logoutSuc.jsp</result>
                <result name="error">/Error.jsp</result>
            </action>
        </package>
    </struts>
    struts.xml
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
       "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
       "http://struts.apache.org/dtds/struts-2.3.dtd">
    <struts>
       <include file="struts-default.xml" />
       <include file="struts-itcast.xml" />
    </struts>
    Error.jsp
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <title>Error</title>
    </head>
    <body>
    <h1>Error</h1>
    </body>
    </html>
    F  login.jsp
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
       <head>
       </head>
       <body>
          <a href="Login_checkLogin.action">login</a>
       </body>
    </html>
    loginSuc.jsp
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head><title>login success</title></head>
      <body>
        <h1>Login Success! </h1>
      </body>
    </html>
    logout.jsp 
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
      <body>
         <a href="Logout_checkLogout.action">logout</a>
      </body>
    </html>
    logSuc.jsp
    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head><title>logout success</title></head>
      <body>
        <h1>Logout  Success! </h1>
      </body>
    </html>
     

     
  • 相关阅读:
    html5内容嵌入元素
    thinkphp默认路径访问报错
    LNMP安装教程
    wampserver的mysql启动与环境变量设置
    http响应详解_韩顺平PHP视频听课笔记
    http请求详解,防盗链技术_韩顺平PHP视频听课笔记
    使用js写一个作用于xml文件的ajax
    使用js创建一个简单的ajax
    js写一个ajax错误规避
    使用js写一个原生态简单的ajax
  • 原文地址:https://www.cnblogs.com/jianfengyun/p/3634586.html
Copyright © 2011-2022 走看看