Solve problems with Chinese information support in lookupdispatchaction

xiaoxiao2021-03-06  47

Regarding this problem, you must first understand the JSP page data ------ Actionform - - to ---- Action sequence, in general, the data submission of the JSP page is nothing more than a get mode or POST mode, through Request can be obtained, so all Chinese information support issues when using lookupdispatchaction, is on this intermediate link ---- Formbean. The reason for this problem is that the default code is ISO, and the data incorporated from JSP includes GBK, so after it is in the action, because lookupdispatchaction is to find Key according to Value, and Value does not know, so there is an error. . The solution is: Specially write an actionform for this action, this ActionForm To set the Request's encoded type, so that the data transmitted to the background is consistent, so it is still recognized. The following is: 1. Definition of FORMBEAN in Struts-Config.XML 2, Action configuration: 3, requestform package com.frame.webframe.portal;

import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; import java.io *;. import org.apache.commons.logging.Log; import Org.apache.commons.logging.logfactory;

public class RequestForm extends ActionForm {Log log = LogFactory.getLog (RequestForm.class); public void reset (ActionMapping mapping, HttpServletRequest request) {try {request.setCharacterEncoding ( "GBK");} catch (UnsupportedEncodingException ex) {log.error ("Encoding Error!", EX);}}} 4, an example of the resource file (for the above GBK code) CreateApplyform.saveApplyform = / u4fdd / u5b58 / u7533 / u8bf7 / u5355 has the above example, you use lookupdispatchaction more Happily

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

New Post(0)