Redian新闻
>
spring mvc 里面 view 必须是 jsp吗?
avatar
spring mvc 里面 view 必须是 jsp吗?# Java - 爪哇娇娃
s*s
1
为什么html page 做view page 就不行? 报错:
no mapping found for http request with uri in Dispatherservlet...
jsp page 就没问题.
现在用的是internalresourceviewresolver.
我的mapping没有问题.





改成 ".html"/> 就不行了. 不知道为什么? 难道不能用"internalresourceviewresolver"?
avatar
f*3
2
那你看Dispatherservlet.xml的mapping啊

【在 s****s 的大作中提到】
: 为什么html page 做view page 就不行? 报错:
: no mapping found for http request with uri in Dispatherservlet...
: jsp page 就没问题.
: 现在用的是internalresourceviewresolver.
: 我的mapping没有问题.
:
:
:

avatar
x*d
3
可以是excel,pdf,sitemesh,tiles,thymeleaf,xml,json,可以设的,怎么设查
文档吧。
avatar
x*d
4
通常是在这个文件里设view resolver, 和suffix。

【在 f**********3 的大作中提到】
: 那你看Dispatherservlet.xml的mapping啊
avatar
x*d
5
设成html不是不行,但怎么把那个m传个v呢? 用html就不是mvc了吧?
avatar
s*s
6
什么意思, 详细解释下?

【在 x****d 的大作中提到】
: 设成html不是不行,但怎么把那个m传个v呢? 用html就不是mvc了吧?
avatar
x*d
7
mvc is model view contriller, right.
using html, you got v, your controller can dispatch the request to view/html
. but how can the view get model/data? supposed it should be controlled by
the controller, too, right?
if you don't need model that is controlled by the controller, why you need
controller in the first place, you can serve html directly. vc = v(only).
if you use javascript to get data into html, that is not mvc no more, either.

【在 s****s 的大作中提到】
: 什么意思, 详细解释下?
avatar
s*s
8
你的解释不能完全同意.
1. html page 可以接收data, 比如用thymeleaf.
2. 我现在的问题是, 我的html page不需要从model那里拿到data. 这样也不能用在
spring mvc上吗?
但是相反,如果一个jsp page不需要从model那里拿到data, 它也能作为spring mvc的
view.
那问题就是: html page 能不能做为spring mvc的view吗?
我觉得应该跟viewresolver的设置有关,但读了半天,还没找到.

html
either.

【在 x****d 的大作中提到】
: mvc is model view contriller, right.
: using html, you got v, your controller can dispatch the request to view/html
: . but how can the view get model/data? supposed it should be controlled by
: the controller, too, right?
: if you don't need model that is controlled by the controller, why you need
: controller in the first place, you can serve html directly. vc = v(only).
: if you use javascript to get data into html, that is not mvc no more, either.

avatar
d*i
9
为什么不直接用rest呢? 这样不简单些吗?

view

【在 s****s 的大作中提到】
: 为什么html page 做view page 就不行? 报错:
: no mapping found for http request with uri in Dispatherservlet...
: jsp page 就没问题.
: 现在用的是internalresourceviewresolver.
: 我的mapping没有问题.
:
:
:

avatar
x*d
10
i see. if that is the case, easy. use this code.
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">



avatar
x*d
11
or you can tell the container use jsp engine to serve html.

jsp
*.html


ServletContextTemplateResolver">

【在 x****d 的大作中提到】
: i see. if that is the case, easy. use this code.
: : class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
:
:
:
:

avatar
s*s
12
这个work.
我觉得问题应该是:
default servlet 是jsp servlet. 所以, in order to handle .html, we need
regist .html
to jsp servlet engine.

【在 x****d 的大作中提到】
: or you can tell the container use jsp engine to serve html.
:
: jsp
: *.html
:

:
: ServletContextTemplateResolver">

avatar
f*3
13
不就是这一行

该了就行了

view

【在 s****s 的大作中提到】
: 为什么html page 做view page 就不行? 报错:
: no mapping found for http request with uri in Dispatherservlet...
: jsp page 就没问题.
: 现在用的是internalresourceviewresolver.
: 我的mapping没有问题.
:
:
:

avatar
x*d
14
关键是没有这个use case,你说说为啥您非要用html?

【在 s****s 的大作中提到】
: 这个work.
: 我觉得问题应该是:
: default servlet 是jsp servlet. 所以, in order to handle .html, we need
: regist .html
: to jsp servlet engine.

avatar
d*i
15
现在是不是都用HTML5了?JSP好像有点过时了吧。

【在 x****d 的大作中提到】
: 关键是没有这个use case,你说说为啥您非要用html?
avatar
x*d
16
jsp不是html5么?有啥关系?

【在 d****i 的大作中提到】
: 现在是不是都用HTML5了?JSP好像有点过时了吧。
avatar
s*s
17
我刚调通了,both .jsp and .html can be as view page now. 原因应该就是那个.
case应该有吧, 我目前还在学习阶段, 没有太多的认识.

【在 x****d 的大作中提到】
: 关键是没有这个use case,你说说为啥您非要用html?
avatar
d*i
18
server-side technology vs. client-side technology,现在不管什么做backend,趋
势是Python, PHP,Java, Ruby, Node, Perl, .NET的都基本上把server-side
rendering给换成纯客户端的HTML5了。

【在 x****d 的大作中提到】
: jsp不是html5么?有啥关系?
avatar
x*d
19
学习阶段你折腾这个干啥?use case实际工作中怎么会有?

【在 s****s 的大作中提到】
: 我刚调通了,both .jsp and .html can be as view page now. 原因应该就是那个.
: case应该有吧, 我目前还在学习阶段, 没有太多的认识.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。