问题
In PHP there is the die("some message"); to write output and stop the execution of the script. So is there an equivalent in Spring mvc ( in Controller and in the JSP ) ?
回答1:
There is no reason to have something like die() in Java/JSPs. JSPs should be used as a pure view technology. It should just generate HTML. Not try to access a database, read files or whatnot. That is the job of a controller, written in Java
Use System.exit(0); to exit the java code.
Keep a note this will stop the JVM instance which is currently running.
If you want to come out of a method use return or throw exception to showcase error condition.
来源:https://stackoverflow.com/questions/39158564/what-is-the-equivalent-of-die-in-spring