gpt4 book ai didi

java - spring war 文件部署到 tomcat 9 但没有正确重定向?

转载 作者:行者123 更新时间:2023-11-28 23:09:53 24 4
gpt4 key购买 nike

应用程序工作并重定向到本地机器上的 View 。

http://localhost:8080/login

一旦部署在 aws 服务器上的项目 war 文件 orbiter.war 项目正在运行并获取登录页面。

http://ec2.__compute__amazonaws.com:8080/orbiter/ enter image description here

登录后重定向到404 未找到的欢迎 View

http://ec2.__compute__amazonaws.com:8080/welcome enter image description here

但是当我去轨道飞行器/welcome manully its redirecting.

http://ec2.__compute__amazonaws.com:8080/orbiter/welcome

enter image description here

登录 Controller

@RequestMapping(value = { "/", "/login" }, method = RequestMethod.GET)
public String showLoginPage() {
return "login";
}

@RequestMapping(value = "/login", method = RequestMethod.POST)
public String handleUserLogin(ModelMap model, @RequestParam String name, @RequestParam String password) {
return "redirect:welcome";
}

@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public String showWelcomeDashboard(ModelMap model) {
LOG.info(" Welcome to Orbiter");
//LOG.info("User Count"+loginDao.msJdbcTest());
//model.put("vList",null);
return "welcome";
}

web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<!-- webapp/WEB-INF/web.xml -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Orbiter</display-name>
<welcome-file-list>
<welcome-file>login.do</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

调度程序 servlet 文件 spring-servlet.xml

<!-- Configuration defining views files -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>

<mvc:resources mapping="/webjars/**" location="/webjars/"/>
<mvc:resources mapping="/assets/**" location="/assets/" cache-period="31556926" />

最佳答案

显然您的 url 映射不正确。

此 url 不为应用程序提供服务:

http://ec2.__compute__amazonaws.com:8080/welcome

但是这个是有效的:

http://ec2.__compute__amazonaws.com:8080/orbiter/welcome

因此请更正您的映射并将其指向orbiter/welcome,也许您犯了一些愚蠢的错误。

关于java - spring war 文件部署到 tomcat 9 但没有正确重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59135141/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com