Does the Struts2 tutorial have misnamed files? HelloWorldAction in HelloWorld.java

StackOverflow https://stackoverflow.com/questions/22115697

  •  18-10-2022
  •  | 
  •  

문제

I am going through the Struts2 tutorial at http://struts.apache.org/release/2.2.x/docs/hello-world-using-struts-2.html

They have a file HelloWorld.java that defines a class HelloWorldAction and the compiler (as run from ant) complains:

[javac] HelloWorld.java:6: class HelloWorldAction is public, should be declared in a file named HelloWorldAction.java

Obviously I can fix this, but is the tutorial really this wrong, or is there some configuration setting that I am missing? I already fixed this once with the tutorial having class MessageStore defined in Message.java and I'm wondering if I'm missing something.

도움이 되었습니까?

해결책

The caption says

Step 2 - Create The Action Class HelloWorldAction.java

So just rename the file that's probably the typo. There are no such config. Java always wants you to name files accordingly.

다른 팁

Yes, it is wrong. You need to name it HelloWorldAction.java

enter image description here

public class Foo

must always be named Foo.java no matter what framework you are using or javac will complain.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top