Struts comes with an example of an example (2)

zhaozj2021-02-16  45

Take Subscription.jsp as an example, introduce server-side check, resource binding, and internationalization.

Subscription.jsp

Subscription.jsp is used by server-side checks.

Subscription. JSP screen The corresponding action is SAVESUBSCRIPTION.

There is a check function validate in the SubscriptionForm.

The Validate function verified by Host, UserName, Password, and Type, respectively. If there is an error, generate the corresponding actionerror, then put it in an ActionerRors object, and finally returns this object.

Resource binding:

Describes the error message used in Actionerror error.host.required, which is saved to the resource file. The resource file has several ApplicationResources.properties, ApplicationResources_ja.properties, ApplicationResources_ru.properties.

If your IE default language is in English, the ActionServlet will take the information you need in the applicationResources.properties this file. If your IE default language is Japanese, the ActionServlet will take the ActionServlet to ApplicationResources_ja.properties file when you visit. Information required. If your default language is Chinese, ActionServlet can't find the corresponding resource file, it uses ApplicationResources.properties in English.

Resource binding also supports internationalization (I18N - 18 characters between I and N). You can create ApplicationResources_xx.properties for other languages ​​of ISO language code to XX.

In addition to English, Chinese and Japanese, in English, Chinese and Japanese, etc., you can use Java's own native2ascii.exe to transfer.

to be continued. . .

Related Links:

Struts comes with example introduction (1)

http://www.9cbs.net/develop/read_article.asp?id=25989

转载请注明原文地址:https://www.9cbs.com/read-26261.html

New Post(0)