我从stripe发送一些变量:param到另一个actionbean,以便在另一个jsp文件中显示它们。问题是,如果变量具有非英语字符,如(ä,ö,...)stripe:param将它们编码为某种有线格式。我在jsp中使用了ecoding标签但是没有用。由于条纹:param在条纹:链接内,它可能是带条纹的东西:链接?例如,如果第一个jsp中的'fname'有一个像'ö'这样的字符,当它在第二个jsp中显示时会将其转换为其他一些字符!知道这里发生了什么吗?
第一个jsp
<stripes:link beanclass="se.theducation.course.ui.action.student.StudentEditExcelAction" event="loadStudent" >
<stripes:param name="fname" value="${array.getStudent().getFirstName() }" />
<stripes:param name="lname" value="${array.getStudent().getLastName() }" />
edit
</stripes:link>
student edit excel action.Java
@UrlBinding("/Student/editExcel.action")
public class StudentEditExcelAction implements ActionBean {
private String fname;
private String lname;
@DefaultHandler
@DontValidate
public Resolution edit() {
return forward("editExcel");
}
@DontValidate
public Resolution loadStudent() {
System.out.println("utbildare: " + school); //TODO delete this later
return forward("editExcel");
}
第二个jsp
<table class="solid" style="margin-top: 5px; padding: 5px; width:900px">
<tr class="solid">
<td class="solid">
<tags:labeled label="Firstname:"><br />
<stripes:text name="fname"/>
</tags:labeled>
</td>
<td class="solid">
<tags:labeled label="Lastname:"><br />
<stripes:text name="lname"/>
</tags:labeled>
</td>
</tr>
</table>
似乎问题是关于编码所以我将以下servlet过滤器添加到我的web.xml,它的工作原理!
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
对我来说,工作的例子是:
将该类复制到您的项目中,然后将其包含在web.xml中
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>project.name.SiteFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
对我来说,解决方案是添加
<init-param>
<param-name>LocalePicker.Locales</param-name>
<param-value>fr_FR:UTF-8</param-value>
</init-param>
在web.xml中过滤器StripesFilter
的配置中,如下所示:https://stripesframework.atlassian.net/wiki/spaces/STRIPES/pages/492001/Localization