zoukankan      html  css  js  c++  java
  • Struts2的学习-属性驱动和模型驱动

    1.新建空项目,并托管到码云

    2.设立maven

    3.设置pom.xml

    4.建包

    5.在java包里建立两个类

    package com.nf.entity;
    
    public class User {
        private String userName;
        private String userPassword;
    
        public String getUserName() {
            return userName;
        }
    
        public void setUserName(String userName) {
            this.userName = userName;
        }
    
        public String getUserPassword() {
            return userPassword;
        }
    
        public void setUserPassword(String userPassword) {
            this.userPassword = userPassword;
        }
    }

    (ps:可以使用Alt+Enter导出实现方法)

     6.建立jsp的文件

    7.建立struts,并设置

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE struts PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
            "http://struts.apache.org/dtds/struts-2.5.dtd">
    
    <struts>
        <package name="mypack" extends="struts-default">
            <action name="userAction_loginView" class="com.nf.action.UserAction" method="loginView">
                <result name="success">/WEB-INF/jsp/loginView.jsp</result>
            </action>
            <action name="userAction_login" class="com.nf.action.UserAction" method="login">
                <result name="success">/WEB-INF/jsp/success.jsp</result>
                <result name="error">/WEB-INF/jsp/error.jsp</result>
            </action>
        </package>
    </struts>

    8.当点击运行时

     地址:https://gitee.com/MuNianShi/user2.git

  • 相关阅读:
    Luogu P5853 [USACO19DEC]Tree Depth P
    Luogu P6009 [USACO20JAN]Non-Decreasing Subsequences P
    HDU6309 Absolute
    Luogu P4734 [BalticOI 2015]Hacker
    Gym102431F Ferry
    Gym102431G Game on the Tree
    AGC018F Two Trees
    Gym102268D Dates
    AGC023F 01 on Tree
    CF700E Cool Slogans
  • 原文地址:https://www.cnblogs.com/junhua4254/p/7593749.html
Copyright © 2011-2022 走看看