chkal / mvc-spec-migration-test

0 stars 0 forks source link

Document support redirect #44

Closed chkal closed 8 years ago

chkal commented 9 years ago

Original issue MVC_SPEC-45 created by Santiago Pericas-Geertsen:

Need to document forms of redirect.

chkal commented 8 years ago

Comment by Santiago Pericas-Geertsen:

Spec document updated.

chkal commented 8 years ago

Comment by Christian Kaltepoth:

Perhaps we should include some words about how absolute and relative paths are resolved here. I didn't check the current implementation in Ozark yet, but I would expect it like this. Say the application is deployed to the context path /myapp and JAX-RS uses the application path /resources:

||Controller result||Location Header in Response|| |redirect:resources/foobar|/myapp/resources/foobar| |redirect:/resources/foobar|/myapp/resources/foobar| |redirect:http://www.java.net/|http://www.java.net/|

The last example is something that Spring MVC supports. It is quite nice, but I'm not strong on this one. It would be OK to tell people to use a Response in this case.

We could even automatically add the application path. In this case it would look like this:

||Controller result||Location Header in Response|| |redirect:foobar|/myapp/resources/foobar| |redirect:/foobar|/myapp/resources/foobar|

chkal commented 8 years ago

Comment by Santiago Pericas-Geertsen:

Unless there's a good reason not to (which I can't think at the moment), our String-based support should be compatible with JAX-RS:

https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/core/Response.html#seeOther(java.net.URI)

That's why I didn't get into too much detail about relative path resolution, although I don't see a problem expanding on this. Using a different algorithm for resolution could be very confusing when mixing styles.

chkal commented 8 years ago

Comment by Christian Kaltepoth:

This would mean that currently it would work like this:

||#||Controller result||Location Header in Response|| |A|redirect:foobar|/myapp/resources/foobar| |B|redirect:/foobar|/foobar| |C|redirect:http://www.java.net/|http://www.java.net/|

I'm fine with A & C. That is exactly like I would expect it. However, I'm not sure about B. That looks weird to me. Typically URLs (even if starting with a /) are relative to the context path. Like in web.xml for example. And with JSF you also return something like /foobar.xhtml?faces-redirect=true.

chkal commented 8 years ago

Comment by Christian Kaltepoth:

Oh sorry, I just checked the Ozark code. Actually the leading slash is stripped from the path.

https://github.com/spericas/ozark/blob/master/ozark/src/main/java/com/oracle/ozark/core/ViewResponseFilter.java#L156

So it is currently implemented like this:

||#||Controller result||Location Header in Response|| |A|redirect:foobar|/myapp/resources/foobar| |B|redirect:/foobar|/myapp/resources/foobar| |C|redirect:http://www.java.net/|http://www.java.net/|

This is absolutely fine for me. Sorry for the confusion.