Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 String[] parameter instead of Long
    primarykey
    data
    text
    <p>I am developing a struts2 application (Struts 2.3.14, java 1.7, on a Tomee plus 1.5.1 server).</p> <p>I have a bunch of "detail" actions, and all of them contain the following code:</p> <pre><code>private Long modelId; public Long getModelId() { return modelId; } public void setModelId(Long modelId) throws Exception { this.modelId = modelId; (...some other stuff...) } </code></pre> <p>In every action I also have a "persist" action that I use to save data, like this one: </p> <pre><code>@Action(value = "persistEntity", results = { @Result(name = "success", location = "entityDetail", type = "redirectAction", params = {"modelId", "%{modelId}"}) }) public String persist() throws Exception { this.modelId = [save method invocation] return "success"; } </code></pre> <p>After saving I try to redirect the user back to the detail page, but I get the following error:</p> <pre><code>Unexpected Exception caught setting 'modelId' on 'class classpath.DetailAction': Error setting expression 'modelId' with value '[Ljava.lang.String;@43b5d2fe' </code></pre> <p>So, it seesm like Struts is handling my masterId as a String array... I had a look at <a href="https://stackoverflow.com/questions/13612506/why-is-struts2-converting-my-string-to-a-string-array">this question</a>, but it was no help for me.</p> <p>What is most strange to me, after I get this error I get the same error every time I try to enter an existing entity, but if I restart my application I can enter existing entities without any error.</p> <p>Thank you! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload