Struts Experience (II.)

Source: Internet
Author: User

Summarize:

The name of the package in Struts.xml can be arbitrarily defined and used only for inheritance.

<package name= "..." abstract= "true" >

The package cannot have an action definition and can only be defined by package inheritance.

In order to make the program easy and quick to use, it is necessary to learn the path dynamic calling code of struts as follows:

<action name= "a_*" class= "Action.submit"  method= "{1}" >  <result name= "{1}" >/{1}.jsp</result ></action>

This way, you can automatically find the specified method in the Java class

Public String A () {    system.out.print ("1");  Return "a";}

  

<a href= "A_a" ></a>

  

Precautions:

This method requires a JSP page, a method in Java, and the return value of a method in Java, which must be the same.

If not, 404 of these errors will occur frequently.

Also note that custom form fields have duplicate names.

Experience Summary:

Filterdispatcher-----Core Controller

Each action-------Business controller

<s:fielderror cssstyle= "color:red" >
<S:param>username</s:param>
</s:fielderror>

Remove the previous "origin", you need to modify the FIELDERROR.FTL template, remove the previous point code

When writing struts2, in return, remember that SUCCESS is defined in action, which is a constant, if written as a string literal of "SUCCESS". If you write a string literal, you need to <resutl name= "your string literal" >xxx.jsp or xxx.html</result>

JSP page to be added at the beginning: <%@ taglib prefix= "s" uri= "/struts-tags"%>

About displaying HTML-formatted content in <s:property value= "xx"/>. Use the Escape property to determine whether to parse HTML-formatted content.

Struts Experience (II.)

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.