There is an inconsistency in how DXA resolves normal and contextual views.
Short story
- Set
dxa.web.views.folder=/
in dxa.properties
.
- Add your views to
<YOUR_WEBAPP>/src/main/resources/WEB-INF/Views/<PATH_TO_VIEW>
.
In your case: /src/main/resources/WEB-INF/Views/Core/Entity/Article.iphone.jsp
.
Notice that this will brake contextual view resolve from modules. We don't have any in DXA though.
Screenshot of my IDE
Long story
Contextual views are being checked whether they exist in classpath${dxa.web.views.folder}/WEB-INF/Views/<ViewName>
. dxa.web.views.folder
is set to /META-INF/resources/
by default, so for Article.iphone
view the path is classpath:/META-INF/resources//WEB-INF/Views/Core/Entity/Article.iphone.jsp
.
At the same time, ViewResolver tries to resolve the view from either classpath:/WEB-INF
or <webapp>/WEB-INF
(one level up from the classpath). For JARs it also tries classpath:/META-INF/resources/WEB-INF
.
So while for views from JAR, both default check&resolve will find a JAR in a /META-INF/resources/WEB-INF
, for web application check in META-INF
will pass but resolve fail. You need either to set both to classpath root in a webapp or create your own module to solve this issue. See short story. :)