html页面直接打开可以,但是struts2跳转至就会乱码,是怎么回事??

html-css013

html页面直接打开可以,但是struts2跳转至就会乱码,是怎么回事??,第1张

乱码问题发生于编码方式不统一造成的,我来说一下我遇到乱码时的查找过程

1,看看项目的编码方式是否是UTF-8

2,看看html页面的编码方式是否是UTF-8

3,看看struts2的接传值编码方式是否是UTF-8,看看属性里的编码方式是否更改了。

如果还是乱码我一般会在项目里直接建立一个html空页面,然后把原html的源代码复制到刚刚建立的html空页面里,这样也能解决问题。

struts中的html.tld是html标签:

tag标签的配置文件,假如写了个tag名叫 public class testTag extends TagSupport{

//your code

}

之后你在tld文件里配置一下

<tag>

<name>testTag </name>

<tag-class>

testTag

</tag-class>

<description>test</description>

<attribute>

<name>forward</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

<description>

<![CDATA[

tag说明

]]>

</description>

</attribute>

<attribute>

<name>tag要传的参数</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

<description>

<![CDATA[

参数说明

]]>

</description>

</attribute>

</tag>

<tag>

之后在jsp文件了就可以调用了。