У меня есть это приложение весной, сервер tomcat, имеющий конечную точку, и я не могу понять, почему я не могу получить доступ к конечной точке приложения.
Основные части кода ниже
привет. jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
Hello ${name}
</body>
</html>
helloweb-servlet. xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.springcore"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
HelloResource
package com.springcore;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/home")
public class HelloResource {
@GetMapping
public ModelAndView getString(){
ModelAndView modelAndView = new ModelAndView("hello");
modelAndView.addObject("name", "nae bara");
return modelAndView;
}
}
и когда я запускаю приложение с помощью tomcat из IntelliJ введите описание изображения здесь
При попытке go на localhost: 8080 / home я получаю следующее введите описание изображения здесь
Консоль Tomcat имеет следующий вывод
/usr/local/apache-tomcat-9.0.33/bin/catalina.sh run
[2020-05-07 11:11:27,824] Artifact springcore:war exploded: Waiting for server connection to start artifact deployment...
07-May-2020 23:11:28.713 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.33
07-May-2020 23:11:28.715 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 11 2020 09:31:38 UTC
07-May-2020 23:11:28.715 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.33.0
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Mac OS X
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.14.5
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86_64
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/jre
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_221-b11
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /Users/username/Library/Caches/IntelliJIdea2019.1/tomcat/Unnamed_springcore
07-May-2020 23:11:28.716 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/apache-tomcat-9.0.33
07-May-2020 23:11:28.717 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/username/Library/Caches/IntelliJIdea2019.1/tomcat/Unnamed_springcore/conf/logging.properties
07-May-2020 23:11:28.718 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
07-May-2020 23:11:28.719 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
07-May-2020 23:11:28.719 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
07-May-2020 23:11:28.719 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
07-May-2020 23:11:28.720 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=/Users/username/Library/Caches/IntelliJIdea2019.1/tomcat/Unnamed_springcore/jmxremote.password
07-May-2020 23:11:28.720 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=/Users/username/Library/Caches/IntelliJIdea2019.1/tomcat/Unnamed_springcore/jmxremote.access
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/uesrname/Library/Caches/IntelliJIdea2019.1/tomcat/Unnamed_springcore
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/apache-tomcat-9.0.33
07-May-2020 23:11:28.722 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/apache-tomcat-9.0.33/temp
07-May-2020 23:11:28.723 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/username/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
07-May-2020 23:11:29.109 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
07-May-2020 23:11:29.167 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [702] milliseconds
07-May-2020 23:11:29.216 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
07-May-2020 23:11:29.216 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.33]
07-May-2020 23:11:29.229 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
07-May-2020 23:11:29.295 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [125] milliseconds
Connected to server
[2020-05-07 11:11:29,394] Artifact springcore:war exploded: Artifact is being deployed, please wait...
07-May-2020 23:11:30.255 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
07-May-2020 23:11:30.373 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'helloweb': initialization started
07-May-2020 23:11:30.399 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh Refreshing WebApplicationContext for namespace 'helloweb-servlet': startup date [Thu May 07 23:11:30 EEST 2020]; root of context hierarchy
07-May-2020 23:11:30.440 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/helloweb-servlet.xml]
07-May-2020 23:11:30.850 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/home] onto handler 'helloResource'
07-May-2020 23:11:30.850 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/home.*] onto handler 'helloResource'
07-May-2020 23:11:30.851 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.registerHandler Mapped URL path [/home/] onto handler 'helloResource'
07-May-2020 23:11:30.978 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'helloweb': initialization completed in 604 ms
[2020-05-07 11:11:30,992] Artifact springcore:war exploded: Artifact is deployed successfully
[2020-05-07 11:11:30,992] Artifact springcore:war exploded: Deploy took 1,598 milliseconds
07-May-2020 23:11:31.470 WARNING [http-nio-8080-exec-1] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/springcore/] in DispatcherServlet with name 'helloweb'
07-May-2020 23:11:31.550 WARNING [http-nio-8080-exec-3] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/springcore/] in DispatcherServlet with name 'helloweb'
07-May-2020 23:11:39.238 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/apache-tomcat-9.0.33/webapps/manager]
07-May-2020 23:11:39.264 INFO [Catalina-utility-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/apache-tomcat-9.0.33/webapps/manager] has finished in [26] ms
07-May-2020 23:11:40.908 WARNING [http-nio-8080-exec-5] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/springcore/] in DispatcherServlet with name 'helloweb'