Search code examples
jqueryajaxjspjsp-tags

Loading jsp page using jQuery .load() causes issue with fmt:message


I have jsp page that I want to load using .load() function and in page that I want to load there are fmt's, < fmt :message key="some_text"/ >, < select> filters and so on. Everything works "perfectly". Page loads, fmt's load. But the problem is that after I spend 10 minutes or so on that page and and want to use filters, and when page reloads fmt's are not loaded. I get something like this ???some_text???.

Here is the ajax call

$('#some_div').load('/ajax/re/load.jsp', ajaxOptions);

And here is the load.jsp file

<%@taglib prefix="sw" uri="/WEB-INF/sw.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="menu" tagdir="/WEB-INF/
<div id="js-search-box" class="search-box">
    <label>
        <input id="div_id_${param.itemId}" type="text" placeholder="   <fmt:message key="search"/>">
        <i class="fa fa-search"></i>
    </label>
</div>

Did anyone had similar problem? Thanks


Solution

  • I know it's an old question, but I've had the same problem today and this is the only thing that popped up on google and it hasn't been answered.

    My problem (and the one in the question) was that i forgot to put encoding for the page.

    Put <%@page pageEncoding="utf-8" contentType="text/html"%> at the top and you'll be fine.

    Otherwise, if this wasn't your problem, then your bundles are probably getting mixed up. Set them again at the begging of your page with <fmt:setBundle ... and <fmt:setLocale ...