java struts2 demo,Struts2 Demo

下面两张图,用 viso 画了1个小时~ viso 很强大啊!

工作原理

fb0e8807467fe6febdffdb48f79284ea.png

Struts2原理.png-163.3kB

工作流程

e2c6386e7195aefede972dfb8314d19f.png

Struts2步骤.png-284.9kB

Hello World Demo

a56402a550fabc4fd41fc81a524002b8.png

1.png-14.5kB

web.xml

配置 Struts 2

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

HelloWorld.jsp

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2

/*

struts.xml

配置每个Action。

/p>

"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

"http://struts.apache.org/dtds/struts-2.3.dtd">

/HelloWorld.jsp

/welcome.jsp

HelloWorld.jsp

登录界面
账号
密码

welcome.jsp

欢迎界面

welcome!

LoginAction.java

package action;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

private String account;

private String password;

public String getAccount() {

return account;

}

public void setAccount(String account) {

this.account = account;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

@Override

public String execute() throws Exception {

if ("yano".equals(account) && "123456".equals(password)) {

return SUCCESS;

}

return LOGIN;

}

}

下载链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值