ITPub博客

首页 > IT职业 > IT图书 > JAVA_Struts2学习小计

JAVA_Struts2学习小计

IT图书 作者:usli 时间:2021-09-09 09:06:00 0 删除 编辑

1、web.xml


HelloWorldStruts2

index.jsp


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


struts2
/*


2、struts2.xml

br/> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- url-action-method(exacute())-result(view) -->

<!-- namespace URL的逻辑路径 -->

<!-- action中name可以支持通配符 如hello_* method='{1}'-->

<!-- 可以有多个result 根据action方法返回值与指定的name值匹配
返回相应视图 -->
/helloworld.jsp

<!-- Add your actions here -->


3、action类
package com.pluto.action;

import com.opensymphony.xwork2.ActionSupport;

public class HelloWorld extends ActionSupport
{

private String uname;

@Override
public String execute() throws Exception
{
    return "success_say";
}

public String getUname()
{
    return uname;
}

public void setUname(String uname)
{
    this.uname = uname;
}

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3324/viewspace-2799398/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-14

  • 博文量
    89
  • 访问量
    808