Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse JSF development

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you how to analyze JSF development, the content is very detailed, interested friends can refer to, hope to be helpful to you.

First step, create the web project

There is nothing to say about creating web project under J2ee, but in the past, I always didn't know how to create web applications in eclipse. It was silly enough that I needed plug-ins and provided a full set of plug-ins in myeclipse. But Myeclipse needs to be cracked. It seems that Chinese programmers seldom use genuine ones. To get to the point, you need to select the J2ee enterprse view in Open Perspective in Myeclipse. Then create the web project. This is quite different from delphi's New project. Delphi puts everything that can be new in one window, while eclipse has different views to provide management, which is a kind of progress, plug-in progress. Add JSF Capability is needed next, because this class library (I don't know if it should be called a class library) supports the components needed for JSF development.

The second step is to create bean

In New- à other, there is managed bean under Myeclipse- à web-JSF, the bean can be created together with the Java class file, and the desired attributes can be completed together, and myeclipse can automatically complete the get,set method of the attributes. It's a cool feature.

Step 3, create and edit the jsp file

Under the webroot-- > web-inf of the project, there is a facesconfig.xml file, which is the management file of Javabean. At the same time, it manages the switching relationship between pages and plays the role of navigating pages. What's interesting is that this file has a beautiful design interface, you can create new jsp files on it, and you can drag-and-drop to define the relationship between pages, making the relationship between all pages look intuitive. It feels like a cool design. The navigation of the page is based on a string, so when configuring the navigation relationship, just set the value of From outcome to the return value of the call to the bean method. It is worth noting that JSF only allows string types for navigation values.

Writing Jsp pages is actually very convenient, even if you don't quite understand it, because myeclipse provides drag-and-drop page design, and it's fun to be proficient in writing code directly. I used to hate html code because I thought it was too mechanical and hard to remember, so I had to learn it, but I could save a lot of effort in this drag-and-drop design. Remember to use Java in jsp in the way "" is used, which would be: "# {}" is called directly with bean.

The fourth step is localization

If you need to consider internationalization, you need to create a .properties file, otherwise you can skip it. The .properties file needs to be created in the directory of the source file, otherwise it will not be found when you specify the location. The configuration of the .properties file is very simple, just like an ini file. For example: "username=user name", if you want to display Chinese, you need to convert it to unicode,jdk with a native2ascii gadget that can be easily converted, but each time you copy it, you have to set the edit to "tag". I don't know if there is a more convenient tool. In addition, if you want to support Chinese .properties files, you need to end with _ zh_CN. Use the following form definition in the jsp file:

And then use it just like the classes in Java

For some reason, I typed msg in my myeclipse. Code hints cannot appear when.

Step 5, debug and run

Start tomcat and type url to run it. However, the suffix of a file cannot be .jsp, it must be .faces.

On how to parse JSF development to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report