JavaTemplates-Study Notes 4, javatemplates-

Source: Internet
Author: User

JavaTemplates-Study Notes 4, javatemplates-
Application Call Sequence

This location is weak. The browser http: // localhost: 9000/index.html-> conf/routes-> app/controllers/Application. scala-> def index = Action-> define OK (views.html. index ("Hello World! ")}-> Returns the plain text or HTML content of the body.

This part should also be understood in this way, and most of the languages are similar to each other. (It seems like this)

Understanding view layer

After studying it, I found that index.scala.html under the default file is the content display page main.scala.html is layouts. If you do not understand it, check the information.

The play template is directly based on the Scala language based on HTML. The template file is usually placed under the view directory, and the file uses the ".scala.html" double extension. every template file is a Scala code. You must use the Scala compiler to check the type and syntax and compile it. class executable JVM binary file.

During compilation, playscripts automatically generate the .scala.html Play template file. scala source code files, such as/app/views/index.scala.html template files will generate/target/scala-2.9.1/src_managed/main/views/html/index. template. scala file, which is then compiled into index by the Scala compiler. class.

Parse the index.scala.html file:

@ (Message: String) @ * template input parameter. Its type is String type and its name is message * @ *. You can call the main.scala.html template, input parameter message * @ main ("Welcome to Play") {@ * a Welcome template in play is called to insert a message * @ play1_welcome (message )}

In the playtemplate, the @ symbol represents the following code as the Scala code block. Because the .scala.html file is eventually compiled into the Scala. index.scala.html code block, the template file is treated as an object, and all input parameters declare the type. Java data type.

The annotation code here is written as follows:

@ * I am a comment *@

Since @ is the start of Scala code, it is easy to note.

See the Action in Application. scala Based on index.scala.html.

  def index = Action {    Ok(views.html.index("Hello World!"))  }

The index receives a parameter. Try to receive multiple parameters: index. scala Application. scala main.scala.html:

First, the second parameter is defined in Application. scala.

Def index = Action {OK (views.html. index ("Your new application is ready.", "Where am I "))}

Then define parameters in index.scala.html

@ (Message: String, exmple: String) @ * The declared format here is the same as the format in the Application * @ * The format received in the main here is also 2 * @ main (message, exmple) {@ * inside the method body (I don't know what kind of professional name should be used here, but it is also called the method body .) is the content displayed on the HTML page * @ <p> learning notes </p> <a href = ""> nothing </a>}

Then, let's see how to call main.scala.html.

@(title: String,exmple: String)(content: Html)<!DOCTYPE html>

The header parameter is correctly defined and can be displayed at will. @ content is the HTML code in the @ main () {...} method in the index.scala.html file.


Who has good JAVA study notes?

It is recommended that you first learn javaSE to pass the basic learning, and then learn Servlet and mvc. Then I learned about jsp. Now I want to learn about Struts, Hibernate, Spring, and ibatis frameworks. I also need to know the most basic SQL commands. As for javaME, I don't think it is necessary if you want to do mobile development. Then you have school ME,
1. First, you must learn the basic knowledge of java.
Do not be confused by new technologies. The old technologies are based on java. If the new technologies are not well-founded, the new technologies cannot be understood.
2. Create a java Project
After learning the basic knowledge of java, make a java project to consolidate it. In the project, you will find many problems. By solving the problems, you will learn more about the basic knowledge.
3. Learn basic database knowledge and develop applications
Software development cannot leave the database, master several popular databases: Oracle, SQL server, MySQL, etc.
4. JEE Basics
First, you need to learn the website basics, including HTML, DHTML, and JavaScript. Then you need to learn XML, XML, and JAXP. Then, you need to learn the basics of JEE, including the JEE development environment, RMI/IIOP, and JNDI; finally, I learned how to develop JDBC databases.

5. web Development
Comprehensive JEE web development knowledge: Servlet + JSP + javaBean + TagLib. Here we will develop a complete web application project.

JAVA Study Notes

I have read this book
You just need to watch it.
It was written by Lin Xinliang.
Well written
I suggest you keep this book
It will be better to combine the Basic java data.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.