我正在将一些变量从Stripes:param发送到另一个actionbean,以便在另一个jsp文件中显示它们。
问题是,如果变量具有非英语字符,例如(ä,ö,...)strips:param,则会将它们编码为某种有线格式。我在jsp中使用了编码标签,但没有用。
由于stripes:param在stripes:link内,它可能与stripes:link一样吗?
例如,如果第一个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>


StudentEditExcelAction.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>

最佳答案

似乎问题出在编码方面,所以我在我的web.xml中添加了以下servlet过滤器,它可以正常工作!

<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>

10-07 18:57
查看更多