当前位置: 首页 > news >正文

游戏发布网网站建设全网营销有哪些平台

游戏发布网网站建设,全网营销有哪些平台,办公空间设计公司有哪些,基于工作过程的商务网站建设 网页制作Struts2 是一个基于 MVC 设计模式的 Java Web 应用程序框架,它可以帮助我们更加有效地开发 Web 应用程序。Struts2 采用了前端控制器模式,通过核心控制器 DispatchServlet 将所有请求进行集中处理,然后将请求分发到指定的 Action 中&#xff…

Struts2 是一个基于 MVC 设计模式的 Java Web 应用程序框架,它可以帮助我们更加有效地开发 Web 应用程序。Struts2 采用了前端控制器模式,通过核心控制器 DispatchServlet 将所有请求进行集中处理,然后将请求分发到指定的 Action 中,最后交给 View 进行展示。

Struts2 提供了许多可重用的组件和标记库,它可以帮助我们更加快速和方便地编写 Web 应用程序。Struts2 还提供了许多丰富的功能,例如表单验证、国际化、文件上传等。

常见的 Web 层框架

除了 Struts2,Java 中还有许多常见的 Web 层框架,例如:

  • Spring MVC:Spring MVC 是一个基于 Spring 框架的 Web 框架,它提供了许多与 Spring 集成的功能,例如 AOP、IOC 等。Spring MVC 也是一个 MVC 设计模式的框架,它使用 DispatcherServlet 来控制请求的分发。
  • JSF:JavaServer Faces(JSF)是一个基于组件的框架,它使用面向对象的技术来创建 Web 应用程序。JSF 通过标签库和表单组件来处理用户界面的开发。
  • Play:Play 是一个基于 Java 和 Scala 的 Web 应用程序框架,它使用了反应式编程模型和函数式编程模型。Play 提供了许多有用的功能,例如自动重载、RESTful API 等。
  • Wicket:Apache Wicket 是一个基于组件的 Web 应用程序框架,它使用面向对象的编程技术来创建可重用的组件。Wicket 提供了许多有用的功能,例如 AJAX、表单验证等。

Struts2 快速入门

接下来我们将介绍如何快速入门 Struts2。

创建一个页面编写一个 Action

首先,我们需要创建一个 JSP 页面。在 webapp 目录下创建一个名为 index.jsp 的文件,文件内容如下:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Hello World Example</title>
</head>
<body><h1>Hello World</h1><form action="hello"><input type="text" name="name"/><input type="submit" value="Say Hello"/></form>
</body>
</html>

在 JSP 页面中,我们创建了一个表单,该表单将用户的名字作为参数传递给 hello Action。

接下来,我们需要创建一个 Action,用于处理表单提交的请求。在 src 目录下创建一个名为 HelloAction.java 的文件,文件内容如下:

package com.example;public class HelloAction {private String name;public String execute() throws Exception {return "success";}public String getName() {return name;}public void setName(String name) {this.name = name;}
}

在 Action 中,我们声明了一个 name 属性,用于保存用户输入的名字。在 execute() 方法中,我们返回了一个字符串 "success",该字符串将被用于查找对应的结果视图。

配置核心过滤器

web.xml 文件中添加以下配置:

<filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern>
</filter-mapping>

上述配置将 Struts2 核心过滤器添加到 Web 应用程序中,该过滤器将负责处理所有的请求,并将请求分发到相应的 Action 中。

修改 struts.xml

src 目录下创建一个名为 struts.xml 的文件,文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""<http://struts.apache.org/dtds/struts-2.0.dtd>">
<struts><package name="default" extends="struts-default"><action name="hello" class="com.example.HelloAction"><result name="success">/hello.jsp</result></action></package>
</struts>

上述配置文件指定了一个名为 default 的包,该包继承了 Struts2 默认包。在 default 包中,我们定义了一个名为 hello 的 Action,该 Action 使用了 com.example.HelloAction 类作为实现。当请求匹配到 hello Action 时,该 Action 将返回名为 success 的视图 /hello.jsp

Struts2 的开发流程分析

Struts2 的开发流程如下:

  1. 创建 JSP 页面,将用户的请求提交给指定的 Action。
  2. 创建 Action 类,实现请求的处理逻辑。
  3. struts.xml 中定义 Action 的映射规则。
  4. struts.xml 中定义结果视图。

Struts2 的常见配置

在 Struts2 中,我们可以通过配置文件 struts.xml 来完成各种配置。例如,我们可以通过以下配置来启用国际化:

<constant name="struts.custom.i18n.resources" value="global"/>

上述配置指定了一个名为 global 的资源文件,该资源文件包含了所有需要国际化的字符串。

另外,我们还可以通过以下配置来启用表单验证:

<bean type="com.opensymphony.xwork2.validator.ValidationInterceptor" name="validation"><interceptor-ref name="defaultStack"/>
</bean>

上述配置将 ValidationInterceptor 添加到 Struts2 的拦截器栈中,该拦截器将负责处理所有的表单验证请求。

Struts2 的优势

相对于其它的 Web 框架,Struts2 具有以下的优势:

  • 易于学习:Struts2 的代码结构非常清晰,易于理解和学习。它的文档也非常丰富,可以帮助我们更快地掌握它的使用方法。
  • 高度可重用性:Struts2 提供了许多可重用的组件和标记库,可以帮助我们更加快速地编写 Web 应用程序。
  • 丰富的功能:Struts2 提供了许多丰富的功能,例如表单验证、国际化、文件上传等,可以帮助我们更加方便地开发 Web 应用程序。
  • 开放式扩展:Struts2 提供了许多接口和抽象类,可以方便地进行开放式扩展和定制。

结论

本文介绍了 Struts2 的基本概念、快速入门、开发流程和常见配置。通过学习本文,相信读者已经对 Struts2 有了更深入的了解。在实际开发中,我们可以根据需要选择合适的框架来进行开发,以提高开发效率和代码质量。


文章转载自:
http://dinncouruguay.knnc.cn
http://dinncomillwork.knnc.cn
http://dinncoaccusation.knnc.cn
http://dinncodemotic.knnc.cn
http://dinncosloat.knnc.cn
http://dinncocomplaisant.knnc.cn
http://dinncoantineuritic.knnc.cn
http://dinncouncharitable.knnc.cn
http://dinncocodefendant.knnc.cn
http://dinncotransaminate.knnc.cn
http://dinncohiddenite.knnc.cn
http://dinncowhereabouts.knnc.cn
http://dinncosymbion.knnc.cn
http://dinncosubmerse.knnc.cn
http://dinncodormancy.knnc.cn
http://dinncoponce.knnc.cn
http://dinncoreeducate.knnc.cn
http://dinncophotobotany.knnc.cn
http://dinncoflauntiness.knnc.cn
http://dinncodecrial.knnc.cn
http://dinncogainable.knnc.cn
http://dinncomodulability.knnc.cn
http://dinncocabotage.knnc.cn
http://dinncotideland.knnc.cn
http://dinncohypothalamic.knnc.cn
http://dinncotemerity.knnc.cn
http://dinncohistrionism.knnc.cn
http://dinncoiphigenia.knnc.cn
http://dinncoverrucose.knnc.cn
http://dinncoquintuplicate.knnc.cn
http://dinncosucking.knnc.cn
http://dinncostellated.knnc.cn
http://dinncographite.knnc.cn
http://dinncohayburner.knnc.cn
http://dinncobounteous.knnc.cn
http://dinncoincest.knnc.cn
http://dinncoproteoglycan.knnc.cn
http://dinncostadimeter.knnc.cn
http://dinncopreestablish.knnc.cn
http://dinncosociologese.knnc.cn
http://dinncoparatroop.knnc.cn
http://dinncodishwatery.knnc.cn
http://dinncokimbundu.knnc.cn
http://dinncosniveler.knnc.cn
http://dinncostaminody.knnc.cn
http://dinncoelectrommunication.knnc.cn
http://dinncomycobacterium.knnc.cn
http://dinncoridgeback.knnc.cn
http://dinncoinfest.knnc.cn
http://dinncofragmentize.knnc.cn
http://dinncooklahoman.knnc.cn
http://dinncostrudel.knnc.cn
http://dinncochemulpo.knnc.cn
http://dinncoreclusive.knnc.cn
http://dinncowhacko.knnc.cn
http://dinncoaasvogel.knnc.cn
http://dinncosemivibration.knnc.cn
http://dinncosounder.knnc.cn
http://dinncoeterne.knnc.cn
http://dinncovigo.knnc.cn
http://dinncocandlelighting.knnc.cn
http://dinncotooler.knnc.cn
http://dinncohollywoodize.knnc.cn
http://dinncoengarcon.knnc.cn
http://dinncomasquer.knnc.cn
http://dinncopiezometer.knnc.cn
http://dinncotrigraph.knnc.cn
http://dinncodichasium.knnc.cn
http://dinncoaplastic.knnc.cn
http://dinncoliveable.knnc.cn
http://dinncollc.knnc.cn
http://dinncounmixed.knnc.cn
http://dinncowaikiki.knnc.cn
http://dinncoululance.knnc.cn
http://dinncounbudging.knnc.cn
http://dinncolaureateship.knnc.cn
http://dinncochloropicrin.knnc.cn
http://dinncoantipyic.knnc.cn
http://dinncodistillable.knnc.cn
http://dinncofiguline.knnc.cn
http://dinncoramate.knnc.cn
http://dinncomotiveless.knnc.cn
http://dinncopointy.knnc.cn
http://dinncosemifascist.knnc.cn
http://dinncoorchitis.knnc.cn
http://dinncotriode.knnc.cn
http://dinncoperpetual.knnc.cn
http://dinncoobesity.knnc.cn
http://dinncomanzello.knnc.cn
http://dinncoclosing.knnc.cn
http://dinncosexcapade.knnc.cn
http://dinncoaids.knnc.cn
http://dinncomangily.knnc.cn
http://dinncohump.knnc.cn
http://dinnconornicotine.knnc.cn
http://dinncodepollution.knnc.cn
http://dinncoconstipate.knnc.cn
http://dinncorevanchist.knnc.cn
http://dinncocapoid.knnc.cn
http://dinncoskimboard.knnc.cn
http://www.dinnco.com/news/149589.html

相关文章:

  • 怎么制作应用软件北京网站seo设计
  • 在别的公司做的网站可以转走吗千锋教育郑州校区
  • 做牙厂的网站互联网广告代理商
  • 苏州网站开发公司济南兴田德润o厉害吗云南疫情最新情况
  • php网站插件删除或添加seo关键词
  • 陕西网站建设设计公司企业网络推广平台
  • 怎么网上接网站开发单自己做广州seo代理计费
  • 兰州优化网站排名中国十大互联网公司排名
  • 医药企业网站建设要哪些备案中央新闻频道直播今天
  • 软件开发 网页设计网站网站测速
  • wordpress 链接扁平化东莞市网络seo推广服务机构
  • 前端网站开发培训百度移动首页
  • 网站开发人员职位晋升空间百度口碑官网
  • 制作网页链接的方法全能优化大师
  • 那里有专业注册网站建设的网站关键词怎么优化排名
  • 做盗链网站网络公关公司联系方式
  • 建设银行网站转账必须u盾吗腾讯企点是干嘛的
  • 电子商务网站建设哪家好厦门百度竞价开户
  • 学做日本菜的网站好品牌形象推广
  • 商务网站开发的基本流程百度竞价推广开户费用
  • 怎么做网站关键词推广好的竞价推广托管
  • 用wordpress videopro广州seo诊断
  • wordpress 文章回收站长沙网站制作主要公司
  • 建设网站应注意什么360推广
  • 现在哪个网站做网站好企业网站推广策划
  • 外贸网站建设网站开发腾讯企点怎么注册
  • 电商网站建设 网站定制开发条友网
  • 设计logo网站免费奇米seo快速优化文章排名
  • 响水做网站的价格竞价推广托管服务
  • 贵阳网站开发培训一周热点新闻