Struts2 18 Interceptor (13th)

Source: Internet
Author: User

MultiselectInterceptor the interceptor processes the defaultStack 12th position, which is used to process the select tag where no option is selected. The logic of this interceptor is very similar to that of the CheckboxIntercept interceptor, which is almost identical. When no select tag (multiple = "multiple") is selected, the select tag is not selected, which is similar to the checkbox. Because the interceptor is almost the same as the CheckboxInterceptor interceptor, here is a brief introduction: [java] public String intercept (ActionInvocation actionInvocation) throws Exception {Map parameters = actionInvocation. getInvocationContext (). getParameters (); // obtain the request parameter Map <String, Object> newParams = new HashMap <String, Object> (); Set <String> keys = parameters. keySet (); // The key set of Request Parameters for (Iterator <String> iterator = keys. iterator (); iterator. hasNext ();) {String key = iterator. next (); if (key. startsWith ("_ multiselect _") {// determines whether the key is switched to _ multiselect _ String name = key. substring ("_ multiselect _". length (); // remove the current parameter iterator from the request parameter Map. remove (); // if no option is selected, if (! Parameters. containsKey (name) {// Add a String [] with a length of 0 to newParams. put (name, new String [0]) ;}}// add newParams to the request parameter Map parameters. putAll (newParams); // call the next interceptor return actionInvocation. invoke (); <span style = "font-size: 14px" >}</span>

Related Article

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: 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.