Write the problem when writing a WAP website with the struts framework

xiaoxiao2021-03-31  193

Write a MyActionServlet and override the Process () method in the ActionServlet.

protected void process (HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException {/ ** @ todo Override this org.apache.struts.action.ActionServlet method * / request.setCharacterEncoding ( 'GB2312') ; // add a line and do everything to solve super.process (Request, Response);

Of course, don't forget to change the configuration of Web.xml strutsdemo.myactionServlet Debug 2 config / web -Inf / struts-config.xml 2

This can solve the problem of garbled when the data is submitted, there is a garbled when the page is displayed.

<% response.setContentType ("text / vnd.wap.wml");%> or <% @ Page ContentType = "text / vnd.wap.wml; charSet = UTF-8"%>

In the JSP page, you should display the Chinese to add <% Request.setCharacterencoding ("UTF-8");%>

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

New Post(0)