jspjsp 404页面配置点击登录进入controller报404,是什么原因

springmvc拦截所有请求 不能访问jsp -
- ITeye技术网站
博客分类:
&servlet-name&zhounenghua&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&zhounenghua&/servlet-name&
&url-pattern&/*&/url-pattern&
&/servlet-mapping&
如果在web.xml中这样配置,发现页面报404,无法访问jsp,但是又进了controller。
原因是这样配置对所有请求都进行了拦截,当controller对视图进行分发的时候又被拦截掉了,所以就出现了上面报访问不到jsp的404错误。
&servlet-mapping&
&servlet-name&zhounenghua&/servlet-name&
&url-pattern&/&/url-pattern&
&/servlet-mapping&
谢谢提醒,文章已更正。
浏览 17483
chinahnzhou 写道圣诞王子 写道那我不想直接输入 .jsp怎么设置呢,必须使用controller里面的路径配置,但是转发映射到jsp页面你的意思是:访问的时候不通过.jsp(/xxx.jsp)访问吗?是的呢在这里配置&servlet-mapping&& &&& &servlet-name&zhounenghua&/servlet-name&& &&& &url-pattern&/&/url-pattern&& &/servlet-mapping& /表示拦截所有请求,如果你想以.html方式访问的话&servlet-mapping&& &&& &servlet-name&zhounenghua&/servlet-name&& &&& &url-pattern&*.html&/url-pattern&& &/servlet-mapping& 就可以了
圣诞王子 写道那我不想直接输入 .jsp怎么设置呢,必须使用controller里面的路径配置,但是转发映射到jsp页面你的意思是:访问的时候不通过.jsp(/xxx.jsp)访问吗?是的呢
那我不想直接输入 .jsp怎么设置呢,必须使用controller里面的路径配置,但是转发映射到jsp页面你的意思是:访问的时候不通过.jsp(/xxx.jsp)访问吗?
晕,&url-pattern&/&/url-pattern& 是正确的配置,&url-pattern&/*&/url-pattern&设置后会拦截jsp谢提醒,文章已更正。
chinahnzhou
浏览: 138977 次
来自: 深圳
圣诞王子 写道chinahnzhou 写道圣诞王子 写道那我不 ...
chinahnzhou 写道圣诞王子 写道那我不想直接输入 . ...
圣诞王子 写道那我不想直接输入 .jsp怎么设置呢,必须使用c ...
那我不想直接输入 .jsp怎么设置呢,必须使用controll ...jsp页面跳转到另一个jsp页面 出现404错误_百度知道
jsp页面跳转到另一个jsp页面 出现404错误
onclick=&quot.jsp点击打印按钮跳转到打印页面print?还是我代码有无;.button&button&quot。两个页面在同一目录下;&lt,代码如下; value=&quot从表单页面打印&&quot?本人刚接触java两周,可能是什么原因; text=&quot:&lt,点击打印按钮却出现404错误;javascript.herf=&#39,之前无任何编程基础;/print&quot.&&input&print.jsp' id=& icon=&input art=&quot:window
提问者采纳
你可以直接访问你的print,如果还是404去你的web服务器里面看看你部署的工程里面有没有print,那看看你的文件名是不是写错了既然在同一目录下,如果没写错.jsp 看是不是404
提问者评价
其他类似问题
为您推荐:
其他5条回答
open(' 改成window.jsp'print.location你把window.jsp&#39.herf=&#39
你可以按着xiaomi的回答检查下.另外,检查你的&head&中是否包括了&base href=&&&之类的东西.如果有,可以去掉试试
window.location.herf 错了,正确的是href404是都是配置出错
访问路径出错
404错误的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁11:15 提问
spring-mvc controller能访问到但无法跳转到静态jsp页面
问题很小,但是一直没找出问题来,maven项目build没问题,运行也没问题,就是访问的时候能访问到controller但无法跳转到jsp页面,路径问题还是xml配置问题呢。
求大神指点。。。
这是目录结构
这是web.xml配置和spring-mvc配置
这个是controller
按赞数排序
将jsp文件夹放到WEB-INF下面,然后配置里面
/WEB-INF/jsp/
你把url-pattern 的/* 改为 /
解决问题。
确认一下路径有没有写错
为什么直接用了Dao里的接口,应该用service里面的呀,使用@Resource注入service
在spring-mvc配置文件中加入访问静态文件配置
页面404 是路径不对,后台出错是xml没配置静态文件。、
其他相似问题
相关参考资料jsp页面点击登录进入controller报404,是什么原因?-中国学网-中国IT综合门户网站
jsp页面点击登录进入controller报404,是什么原因?
来源:互联网 发表时间: 15:45:19 责任编辑:鲁晓倩字体:
用户提出问题:jsp页面点击登录进入controller报404,是什么原因?,具体如下:
通过互联网整理获得以下解决方法:=================1楼=====================
应该是URL请求链接打错了吧。
你应该把具体报了什么错贴出来给大家看看的。
=================2楼=====================
404错误是没有找到资源,可能你的web.xml文件没有设置正确。
&welcome-file-list&
&welcome-file&index.jsp&/welcome-file&
&/welcome-file-list&
添加这个试试,
=================3楼=====================
九月&30,&:33&下午&org.springframework.web.servlet.DispatcherServlet&initServletBean
信息:&FrameworkServlet&'spring1':&initialization&started
九月&30,&:33&下午&org.springframework.web.context.support.XmlWebApplicationContext&prepareRefresh
信息:&Refreshing&WebApplicationContext&for&namespace&'spring1-servlet':&startup&date&[Wed&Sep&30&16:30:33&CST&2015];&root&of&context&hierarchy
九月&30,&:33&下午&org.springframework.beans.factory.xml.XmlBeanDefinitionReader&loadBeanDefinitions
信息:&Loading&XML&bean&definitions&from&class&path&resource&[spring-mvc.xml]
九月&30,&:33&下午&org.springframework.web.servlet.DispatcherServlet&initServletBean
严重:&Context&initialization&failed
org.springframework.beans.factory.BeanDefinitionStoreException:&IOException&parsing&XML&document&from&class&path&resource&[spring-mvc.xml];&nested&exception&is&java.io.FileNotFoundException:&class&path&resource&[spring-mvc.xml]&cannot&be&opened&because&it&does&not&exist
相关文章:
上一篇文章:下一篇文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 中国学网 版权所有
京ICP备号-1 京公网安备02号[简单]Spring Mvc返回html页面404错误解决记录 - 小瓜的博客 - ITeye技术网站
博客分类:
以前使用Spring Mvc时候都是返回jsp页面或者ftl页面,昨天想返回html页面,spring-mvc.xml配置如下:
&bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/html/" p:suffix=".html" /&
Controller方法如下:
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String toAddTest() {
return "addTest";
在tomcat下测试,页面一直是404,log日志如下:
[06/05/14 10:44:35:035 GMT+08:00] DEBUG support.DefaultListableBeanFactory: Returning cached instance of singleton bean 'sqlSessionFactory'
[06/05/14 10:44:35:035 GMT+08:00] DEBUG servlet.DispatcherServlet: Successfully completed request
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: DispatcherServlet with name 'spring' processing GET request for [/MyTest/test/add]
[06/05/14 10:44:38:038 GMT+08:00] DEBUG annotation.RequestMappingHandlerMapping: Looking up handler method for path /test/add
[06/05/14 10:44:38:038 GMT+08:00] DEBUG annotation.RequestMappingHandlerMapping: Returning handler method [public java.lang.String com.report.controller.testController.toaddTest()]
[06/05/14 10:44:38:038 GMT+08:00] DEBUG support.DefaultListableBeanFactory: Returning cached instance of singleton bean 'testController'
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: Last-Modified value for [/MyTest/test/add] is: -1
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: Rendering view [org.springframework.web.servlet.view.JstlView: name 'addTest'; URL [/WEB-INF/html/addTest.html]] in DispatcherServlet with name 'spring'
[06/05/14 10:44:38:038 GMT+08:00] DEBUG view.JstlView: Forwarding to resource [/WEB-INF/html/addTest.html] in InternalResourceView 'addTest'
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: DispatcherServlet with name 'spring' processing GET request for [/MyTest/WEB-INF/html/addTest.html]
[06/05/14 10:44:38:038 GMT+08:00] DEBUG annotation.RequestMappingHandlerMapping: Looking up handler method for path /WEB-INF/html/addTest.html
[06/05/14 10:44:38:038 GMT+08:00] DEBUG annotation.RequestMappingHandlerMapping: Did not find handler method for [/WEB-INF/html/addTest.html]
[06/05/14 10:44:38:038 GMT+08:00]
WARN servlet.PageNotFound: No mapping found for HTTP request with URI [/MyTest/WEB-INF/html/addTest.html] in DispatcherServlet with name 'spring'
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: Successfully completed request
[06/05/14 10:44:38:038 GMT+08:00] DEBUG servlet.DispatcherServlet: Successfully completed request
可以看出No mapping found for HTTP request with URI错误导致了404,问题原因:
1 First the DispatcherServlet is invoked by the Servlet Container. 2 The DispatcherServlet finds a mapping which maps to the home method of your Controller and the home method returns a view name "HelloWorld" 3 Now the DispatcherServlet uses a View Resolver (your InternalResourceViewResolver) to find the View to render the model through, since the name is "HelloWorld", this maps to the /WEB-INF/view/HelloWorld.html view. 4 Now essentially a call is made to RequestDispatcher.forward("/WEB-INF/views/HelloWorld.html",.... 5 The Servlet container at this point tries to find the servlet which can handle /WEB-INF/views/HellowWorld.html uri - if it had been a .jsp there is a JSPServlet registered which can handle rendering the jsp, however for *.html there is no servlet registered, so the call ends up with the "default servlet", which is registered with a servlet-mapping of / which probably your DispatcherServlet is. 6 Now the Dispatcher servlet does not find a controller to handle request for /WEB-INF/views/HelloWorld.html and hence the message that you are seeing
解决方法:
Add this servletmapping for the JSP servlet(web.xml): &servlet-mapping& &servlet-name&jsp&/servlet-name& &url-pattern&*.html&/url-pattern& &/servlet-mapping&
再次访问就OK了。
浏览: 111287 次
我复制了你的代码,运行时报错:java.lang.NoClas ...
请问下 poi能不能在word2003上面替换或者插入图片
可以给一个dome吗?doc4j 依赖 log4j,好烦。
[u][u][u][u][u][u][u][u][u][u][ ...
org.openxmlformats.schemas.word ...

我要回帖

更多关于 jsp点击按钮跳转页面 的文章

 

随机推荐