页面请求404消息 /WEB-INF/pageslist.jsp 描述 源服务器未能找到目标资源的表示或者是不愿公开一个已经存在的资源表示。

这里跳转的是springmvc里的页面
原页面应该在pages下面的list.jsp
这里看服务器识别成这个样子:pageslist.jsp
一眼就看到了错误:(如果这篇文章解决你的问题,请点个小赞)
贴错误代码:

<!--配置视图解析器-->
    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

正确的:

前缀路径这里最后加上/,代表这个目录下的所有资源
    <property name="prefix" value="/WEB-INF/pages/"></property>
  • 10
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
以下是一个简单的 Java Servlet 实现判断是否存在名为 `username` 的 Cookie,如果存在则重定向到 `success.html` 页面,否则重定向到登录页面: ```java @WebServlet("/") public class LoginServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Cookie[] cookies = request.getCookies(); boolean hasUsernameCookie = false; if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals("username")) { hasUsernameCookie = true; break; } } } if (hasUsernameCookie) { response.sendRedirect(request.getContextPath() + "/success.html"); } else { response.sendRedirect(request.getContextPath() + "/login.html"); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } ``` 在这个示例中,`doGet` 方法获取所有的 Cookie,并检查是否存在名为 `username` 的 Cookie。如果存在,则重定向到 `success.html` 页面,否则重定向到 `login.html` 页面。 注意,需要在 `web.xml` 文件中配置默认的欢迎页面: ```xml <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> ``` 这里将默认欢迎页面设置为 `index.html`,也就是登录页面。 如果用户已经登录并且存在名为 `username` 的 Cookie,访问默认欢迎页面时会自动重定向到 `success.html` 页面。如果用户没有登录或者名为 `username` 的 Cookie 已经过期,会自动重定向到登录页面

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值