Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ struts2 completely the wrong way to capture 404     - Orionode source Linux Mint installation (Linux)

- Linux productivity tools and tips (Linux)

- The most concise explanation of JavaScript closures (Programming)

- Compression decompression command under Linux (Linux)

- Docker commonly used commands Description (Linux)

- Linux Basic Course: tar command description (Linux)

- Linux / Unix desktops interesting: Christmas tree on the terminal (Linux)

- Nginx Installation and Configuration (Server)

- JVM garbage collector and memory allocation strategy (Programming)

- Report generation CPU, memory, and input and output ports with the sar command (Linux)

- Linux shared libraries .so file name and Dynamic Link (Linux)

- Detailed installation OpenCV2.3.1 under CentOS 6.5 (Linux)

- Ubuntu method for single-card dual-IP (Linux)

- Using nmcli commands to manage network in RedHat / CentOS 7.x (Linux)

- Linux for enterprises to build a firewall (Linux)

- Oracle inverted reverse function (Database)

- Linux raw socket (Programming)

- Bitmap memory footprint of computing Android memory optimization (Linux)

- On the design of Oracle database backup (Database)

- Interesting example of Linux Sort command (Linux)

 
         
  struts2 completely the wrong way to capture 404
     
  Add Date : 2018-11-21      
         
         
         
  Currently doing a web application, struts2 + spring + hibernate, server is tomcat. We want users in the IE address bar Luanqiao when all undefined URL that can be typed into the capture process, then go to a home-made 404 error handling page.

First, access to online information that can be added in web.xml so:

< Error-page>
  < Error-code> 404 < / error-code>
  < Location> /error/404.jsp < / location>
< / Error-page>

Thus, it is not found 404 error will go /error/404.jsp accept the deal.

But after testing, I found that the end of the URL .action struts2 framework will first be captured, not directly into web.xml configured handle page. Thus, if the appropriate action is not configured in struts.xml, an error is output in the tomcat:

Serious: Could not find action or result
There is no Action mapped for namespace / and action name ****** -. [Unknown location]

While the final configuration can be transferred to the web.xml processing page, but this blind at the command station output something very easy to program and debug management, so I have to find ways to deal with struts2 framework undefined action.

Access to online information, can be found in struts.xml, add a default package, then this default package, add a default action, so that the action turned 404 error handling page:

< Package name = "default" extends = "struts-default">
  < Default-action-ref name = "notFound" />
  < Action name = "notFound">
    < Result> /error/404.jsp < / result>
  < / Action>
< / Package>


The default package feature is that you do not define namespace attribute, so all undefined namespace will turn here. name = "default" is for ease of reading, in fact, is what the name can also be empty: name = "".

And then also in the other package has been defined also add the default action, turn to page 404 error handling. So that it can fully handle all the 404 errors.
     
         
         
         
  More:      
 
- RPM package creation Getting Started (Linux)
- Use scripts easily install the latest Linux kernel in Ubuntu (Linux)
- Stucts2 values on the page and how the attribute values corresponding to the Action (Programming)
- Linux System Getting Started Learning: The Linux log (Linux)
- About Git (Linux)
- C ++ overloaded stream insertion operator and the stream extraction operator (Programming)
- Use PuTTY key authentication mechanism for remote login Linux (Linux)
- Installation and deployment of MariaDB under CentOS (Database)
- Qt shared memory interprocess communication (Programming)
- CentOS yum source configuration (Linux)
- Android custom ViewPager create kaleidoscopic image transition effects (Programming)
- CentOS install pip (Linux)
- Install the free open source financial software GnuCash 2.6.6 under Ubuntu (Linux)
- Nginx configuration support f4v video format player (Server)
- CentOS 7 open ports (Linux)
- Sublime Text 3 (Linux)
- MySQL IO SSD attempt at optimization (Database)
- Ubucompilator-Ubuntu, Debian, Linux Mint created deb package of graphical tools (Linux)
- MySQL 5.6 use GTIDs build the master database (Database)
- Oracle 11g statistics collection - collection of multi-column statistics (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.