Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output text is changed(Thymeleaf3) #546

Closed
yKazihara opened this issue Oct 20, 2016 · 6 comments
Closed

Output text is changed(Thymeleaf3) #546

yKazihara opened this issue Oct 20, 2016 · 6 comments

Comments

@yKazihara
Copy link

After I upgraded from 2 to 3, output text is changed.

public class Page {
  public String code;
}

public class SampleAction {
  ...
  Page page = new Page();
  page.code = "APPLE";
  ...
}

<span th:text="${it.code}">ORANGE</span>

・Thymeleaf 2.1.4.RELEASE
 APPLE // OK

・Thymeleaf 3.0.2.RELEASE
 701259 // hashCode?

Could you tell me why the output is changed?

@danielfernandez
Copy link
Member

Nothing should have changed in your case. Are you completely sure that your expression in the second case includes the .code part?

Also, what is the environment? Are you using thymeleaf in a Spring app?

@yKazihara
Copy link
Author

I don't use thymeleaf in a Spring app.

I wrote another sample.
This Junit test was successful.

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;

import org.junit.Test;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

public class Sample {

  public static class Page {
    public String name = "orange";
    public String code = "apple";
  }

  @Test
  public void test() {
    TemplateEngine engine = new TemplateEngine();

    Page page = new Page();
    Context context = new Context();
    context.setVariable("p", page);

    assertThat(engine.process("[[${p.name}]]", context), is("orange"));

    assertThat(engine.process("[[${p.code}]]", context), is(not("apple")));
    assertThat(engine.process("[[${p.code}]]", context),
        is(Integer.toString(page.hashCode())));
  }
}

@danielfernandez
Copy link
Member

This is actually a bug in the OGNL expression language. OGNL is the expression language being used by Thymeleaf in non-Spring applications. See orphan-oss/ognl#32

I'm leaving this open in order to update Thymeleaf's dependency to a future version of OGNL that might fix this.

danielfernandez added a commit to thymeleaf/thymeleaf-tests that referenced this issue Oct 26, 2016
@danielfernandez
Copy link
Member

OGNL 3.1.12 released and Thymeleaf's 3.0 branch updated to use it.

@danielfernandez
Copy link
Member

Already in 3.0.3-SNAPSHOT

@yKazihara
Copy link
Author

Thank you!

danielfernandez added a commit to thymeleaf/thymeleaf-tests that referenced this issue Apr 3, 2017
danielfernandez added a commit to thymeleaf/thymeleaf-tests that referenced this issue Apr 3, 2017
danielfernandez added a commit to thymeleaf/thymeleaf-tests that referenced this issue Apr 4, 2017
danielfernandez added a commit to thymeleaf/thymeleaf-tests that referenced this issue Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants