Java应用程序中的主要方法 [英] Main method in a Java application
问题描述
我们到处都读到要启动Java程序,我们需要一个起点,而这是一个静态的main方法.在Java EE应用程序中,主要方法在哪里.是否内置在应用程序服务器/容器中?它是如何触发的以及我们可以对此进行哪些修改?
Everywhere we read that to kick start a java program we need a starting point and that is a static main method. In a Java EE application where is that main method present. Is it inbuilt in application server/ container? How it gets triggered and what modifications we can do with that?
推荐答案
对于 Java EE
,没有main之类的东西.根据您的配置,所有内容都将绑定到 URL
,该URL将执行与其绑定的 Bean
.如果使用的是 JSF
,则示例为 Faces-config.xml
.如果您使用的是简单的 servlet
,那么它将是 web.xml
.
With Java EE
there is no such thing as main. Depending on your configuration, everything is bind to an URL
which will execute the Bean
it binds to. An example if you are using JSF
would be Faces-config.xml
. If you are using simple servlet
then it would be web.xml
.
然后,Java EE服务器将简单地模拟 POST
或 GET
请求.
The Java EE Server will then simply simulate POST
or GET
request.
另一种可能性是嵌入包含 main
的 Java Applet
,但这不是 Java EE
.
Another possibility would be to embed Java Applet
which would contains a main
, however this is not Java EE
.
运行 main
的程序就是您的服务器.例如 Tomcat
, OC4j
, GlassFish
, Weblogic
等.
The program that is running the main
is your Server. For example Tomcat
, OC4j
, GlassFish
, Weblogic
etc.
这篇关于Java应用程序中的主要方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!