springmvc 登陆跳转的问题 求教```

Awsmsniper 2015-12-28 12:01:49
我现在要做一个登陆跳转的问题,我是把所有资源,包括jsp页面全部都在web-inf/jsp目录下面了,包括login.jsp,我现在启动服务器后,是无法直接访问到login.jsp,那我应该怎么访问到这个页面啊?求教!
...全文
238 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hersing 2015-12-29
  • 打赏
  • 举报
回复
这样也是可以的
<mvc:view-controller path="/" view-name="login"/>
Awsmsniper 2015-12-29
  • 打赏
  • 举报
回复
问题已经解决了,思路就是把静态资源放到WEB-INF的同级目录下,并且在配置文件里面配置静态资源访问(不懂同学可以先百度jsp访问静态资源,因为可以让你学到几种解决办法),然后每个跳转页面都写一个controller进行页面跳转。例如frameset引用其他的页面的时候,需要执行一个对应的controller,才能引用页面:src =${pageContext.request.contextPath}/action/action action方法转发的页面就是frameset要引用的页面。
Awsmsniper 2015-12-29
  • 打赏
  • 举报
回复
引用 5 楼 Tro_picana 的回复:
<!--默认首页设置--> <welcome-file-list> <welcome-file>indexRedirect.jsp</welcome-file> </welcome-file-list>
<%--
  Created by IntelliJ IDEA.
  User: Kevin
  Date: 2014/10/2
  Time: 10:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <link rel="Shortcut Icon" href="${pageContext.request.contextPath}/assert/img/common/logo_i.ico">

    <title></title>
</head>
<body>
    <c:redirect url="${pageContext.request.contextPath}/index/showIndex"></c:redirect>
</body>
</html>
我以前是这么来实现的
嗯,谢谢啦,我已经解决了。
Awsmsniper 2015-12-29
  • 打赏
  • 举报
回复
引用 6 楼 hersing 的回复:
这样也是可以的
<mvc:view-controller path="/" view-name="login"/>
这个没试过,不知道怎么样呢··
树洞丶 2015-12-28
  • 打赏
  • 举报
回复
在web.xml添加

<welcome-file-list>
		<welcome-file>/WEB-INF/jsp/login.jsp</welcome-file>
</welcome-file-list>
然后访问 http://ip:port/项目名称
小白晒太阳 2015-12-28
  • 打赏
  • 举报
回复
<!--默认首页设置--> <welcome-file-list> <welcome-file>indexRedirect.jsp</welcome-file> </welcome-file-list>
<%--
  Created by IntelliJ IDEA.
  User: Kevin
  Date: 2014/10/2
  Time: 10:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <link rel="Shortcut Icon" href="${pageContext.request.contextPath}/assert/img/common/logo_i.ico">

    <title></title>
</head>
<body>
    <c:redirect url="${pageContext.request.contextPath}/index/showIndex"></c:redirect>
</body>
</html>
我以前是这么来实现的
Awsmsniper 2015-12-28
  • 打赏
  • 举报
回复
引用 2 楼 weixin_33382732 的回复:
springMVC 如果访问jsp 需要配置视图解析器 在springMVC 配置文件里
我已经配置了,后来的我就是每个都是跳转页面都写了一个action来进行跳转.谢谢你的回答啊
Awsmsniper 2015-12-28
  • 打赏
  • 举报
回复
引用 1 楼 u010019354 的回复:
在web.xml添加

<welcome-file-list>
		<welcome-file>/WEB-INF/jsp/login.jsp</welcome-file>
</welcome-file-list>
然后访问 http://ip:port/项目名称
然后要写一个action来进行跳转到WEB-INF/jsp里面的jsp页面是么?
yjx_Smile 2015-12-28
  • 打赏
  • 举报
回复
springMVC 如果访问jsp 需要配置视图解析器 在springMVC 配置文件里

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧