当前位置: 代码迷 >> J2EE >> There is no Action 地图ped for namespace / and action name é?±? 乱码
  详细解决方案

There is no Action 地图ped for namespace / and action name é?±? 乱码

热度:574   发布时间:2016-04-21 23:30:28.0
There is no Action mapped for namespace / and action name é????±?????? 乱码
奇葩问题,报错:
ERROR [http-apr-8082-exec-9] (CommonsLogger.java:38) - Could not find action or result
/SchoolInfo/css/%E9%98%B4%E5%BD%B1%E5%9B%BE%E7%89%87
There is no Action mapped for namespace / and action name é????±??????. - [unknown location]

在struts.xml中有一个方法,在index.jsp中通过<s:action>调用,可以调用并将查询内容显示到主页,但查询多几次就报上面的错误,不影响继续查询。
而且在struts.xml,action类中没有css字样,index.jsp中也除了<link>外没有css字样
为什么还乱码了?
有经验前辈指教一下。。
ssh struts 乱码 no?result é????

------解决方案--------------------
貌似乱码不是产生error的根本原因吧。
error是action 找不到啊
------解决方案--------------------
tomcat服务器的编码先设置一下。。
首先:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> 
并且
request.setCharacterEncoding("gb2312");
第二:
 配置 server.xml。

  <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"  URIEncoding="UTF-8"/>
第三:
配置 web.xml  
 <filter>
  <filter-name>setEncoding</filter-name>
  <filter-class>com.dinner.filter.CharsetFilters</filter-class>
  <init-param>
   <param-name>coding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>setEncoding</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>
第四:
工程编码
 开发中发现Windows版Eclipse默认Java和Web工程的默认编码方式不那么遂人愿,修改方法如下:
 1. Web工程文件编码修改方式
 Window -> Preference -> Content types
 推荐将Web相关文件的编码都设置为UTF-8
 2. Java源文件编码修改方式
 Window -> Preference -> Workspace -> Text file encoding
 Windows平台默认为GBK,Linux平台默认为UTF-8

然后看url连接,先保证url连接不乱码

------解决方案--------------------
你这个问题关键不是乱码, 乱码是因为 客户端点击或访问到了不存在的action ,而这个错误的action里有汉字,所以看到了乱码.
action 找不到, 请用后台 debug模式跟踪一下吧,看具体是哪个访问导致的.
  相关解决方案