Finally, the interceptor is the core of the STRUTS2, exception handling

Source: Internet
Author: User

1. The use of finally:
public static int Geta () {
try{
String a = "123";
S.equals ("123");
return 3;
}catch (Exception e) {
return 4;
}finally{
Return 5;//no matter if the exception is not, finally must be executed
}
}
public static void Main (String args[]) {
int A=geta ();
Sysout (a);//a=5
}

2, MySQL garbled problem
Compared to Gbk,utf-8: The range is large, all recognize Chinese


3, development to layered (object-oriented)
Dao (persistence layer) Business Service Layer Control layer

4. servlet process
The display implements the service method, accesses the constructor first, and then Init is loaded once when the servlet is first used.
Servlet cannot do unit tests (servlet is intrusive design mode)

5. Why is struts thread-safe?
Servlet is non-thread safe: Single power, multithreaded mode
Struts: Multithreading, Multi-instance

6. Conceptual Model:


8.15

Process: Create VO entity object, write service layer->action->struts

8.16

404 error: File not found, Interceptor resolved, Interceptor is the core of Struts2

Iterator???

What is the problem in the iterative process??

Interceptors:
<!--configuring Interceptors--
<interceptors>
<!--configuring interceptors to handle encoding format problems--
<interceptor name= "encondinginterceptors" class= "Com.etc.interceptor.EncondingInterceptors" ></ Interceptor>
<!--Interceptor Stack (Interceptor collection)--
<interceptor-stack name= "Mydefaultstack" >
<!--reference your interceptor--
<interceptor-ref name= "Encondinginterceptors" ></interceptor-ref>
<interceptor-ref name= "Defaultstack" ></interceptor-ref>
</interceptor-stack>
</interceptors>
<!--Configure the STRUTS2 default Interceptor--
<default-interceptor-ref name= "Mydefaultstack" ></default-interceptor-ref>


To move an exception to the interface:
<!--global View--
<global-results>
<result name= "Error" >/error.jsp</result>
</global-results>
<!--exception Handling--
<global-exception-mappings>
<!--whenever java.lang.Exception occurs, jump to the error view--
<exception-mapping result= "error" exception= "Java.l ang. Exception "></exception-mapping>
</global-exception-mappings>

This article from "11944396" blog, declined reprint!

Finally, the interceptor is the core of the STRUTS2, exception handling

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.