ITPub博客

首页 > IT职业 > IT职场 > java struts入门程序.

java struts入门程序.

IT职场 作者:yccsunny 时间:2021-09-09 08:58:00 0 删除 编辑
准备:使用maven创建struts2项目

1.首先创建index.jsp,主体一行代

第一次使用strut2

2.创建HelloAction

创建方法say,返回String

public String say(){
return "good";
}

3.配置web.xml,屏蔽所有请求

struts2org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterstruts2/*

4.配置struts.文件xml

/hello.jsp

5.创建hello.jsp

hello struts

工作流程如图

图片描述

注意事项:

maven默认不编译src下面的 .xml文件,需要在pom.xml里面加上

src/main/java**/*.xmltrue

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

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

注册时间:2019-08-30

  • 博文量
    68
  • 访问量
    633