2017-07-24 2 views
0

Ich versuche, eine neue .jsp in meinem WEB-INF/Seiten-Ordner verweisen, aber weiterhin einen Serverfehler (speziell 500). Ich bin neu in Spring, bin also unsicher, wo genau mein Problem liegt, daher habe ich Teile des unten stehenden Codes zur Verfügung gestellt und kann bei Bedarf weitere Details liefern.Serverfehler mit @RequestMapping, um .jsp zu laden

Mein ViewResolver ist:

<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> 
    <property name="contentNegotiationManager" ref="contentNegotiationManager"/> 
    <property name="viewResolvers"> 
      <list> 
       <bean 
    class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
        <property name="viewClass" 
           value="org.springframework.web.servlet.view.JstlView" /> 
        <property name="prefix" value="/WEB-INF/pages/" /> 
        <property name="suffix" value=".jsp" /> 
       </bean> 
      </list> 
     </property> 
     <property name="defaultViews"> 
      <list> 
       <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"> 
        <property name="prefixJson" value="true" /> 
       </bean> 
      </list> 
     </property> 
    </bean> 

während mein Controller ist:

@Controller 
@RequestMapping("/nav") 
public class NavigationController { 
    private static Logger logger = LoggerFactory.getLogger(NavigationController.class); 

    @Autowired 
    private NavigationService navigationService; 

    @Autowired 
    private UserService userService; 

    @RequestMapping("/home") 
    public ModelAndView home() { 
     ModelAndView modelAndView = new ModelAndView("index"); 
     modelAndView.addObject("testimonials", navigationService.getTop5Testimonials()); 
     return modelAndView; 
    } 

    @RequestMapping(value = "/page", method = RequestMethod.GET) 
    public ModelAndView newpage() { 
     ModelAndView modelAndView = new ModelAndView("about2"); 
     return modelAndView; 
    } 

My Dispatcher Servlet ist

<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-3.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> 
    <context:component-scan base-package="com.mazefire.controller"/> 
</beans> 

und die web.xml ist

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     version="3.0" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
    <display-name>MazeFire</display-name> 
    <description>MazeFire Digital Maze Games</description> 

    <welcome-file-list> 
     <welcome-file>/nav/home.do</welcome-file> 
    </welcome-file-list> 

    <servlet-mapping> 
     <servlet-name>MazeFireDispatcher</servlet-name> 
     <url-pattern>*.do</url-pattern> 
    </servlet-mapping> 

Dinge funktionierten Referenzierung Fein die Homepage (index.jsp)

<a href="<c:url value="/nav/home.do"/>" 

verwenden, aber wenn ich versuche, die neue Seite zu verweisen (about2.jsp) hat die Website nicht geladen werden, und ich bekomme den Fehler.

<a href="<c:url value="/nav/page/about2.do"/>" 

Ich fühle das Problem in der für/Funkrufauftrag Syntax ist, würde aber jede Hilfe herauszufinden, zu schätzen wissen, was falsch ist. Wenn weitere Informationen benötigt werden, lassen Sie es mich bitte wissen.

Update: Protokolle zeigen:

27-Jul-2017 11:13:51.283 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 
27-Jul-2017 11:13:56.603 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext 
27-Jul-2017 11:15:25.121 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'MazeFireDispatcher' 
27-Jul-2017 11:16:46.653 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable 
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection 
Caused by: org.hibernate.exception.GenericJDBCException: Could not open connection 
Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure 
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) 
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 
Caused by: java.net.ConnectException: Operation timed out (Connection timed out) 
27-Jul-2017 11:16:46.654 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [MazeFireDispatcher] in web application [] threw load() exception 
java.net.ConnectException: Operation timed out (Connection timed out) 
27-Jul-2017 11:16:46.695 INFO [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext 
27-Jul-2017 11:16:49.653 INFO [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 
27-Jul-2017 11:16:54.980 INFO [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext 
27-Jul-2017 11:18:18.151 INFO [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'MazeFireDispatcher' 
27-Jul-2017 11:19:39.991 SEVERE [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable 
27-Jul-2017 11:19:39.991 SEVERE [RMI TCP Connection(8)-127.0.0.1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [MazeFireDispatcher] in web application [] threw load() exception 
27-Jul-2017 11:19:42.718 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'MazeFireDispatcher' 
27-Jul-2017 11:21:01.341 SEVERE [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable 
27-Jul-2017 11:21:01.341 SEVERE [http-nio-8080-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [MazeFireDispatcher] 
27-Jul-2017 11:21:01.342 INFO [http-nio-8080-exec-9] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'MazeFireDispatcher' 
27-Jul-2017 11:22:23.009 SEVERE [http-nio-8080-exec-9] org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable 
27-Jul-2017 11:22:23.009 SEVERE [http-nio-8080-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [MazeFireDispatcher] 
+0

versuchen Sie '/ nav/page.do', die URL zu einer Methode nicht auf den Speicherort der Datei – tima

+0

Dank @tima, aber es lädt jetzt eine interne Fehlerseite anstelle der about2.jsp, obwohl die URL ist korrekt referenzieren als (http://mazeptilot.com/nav/about.do). Ich baue den Code von jemand anderem aus und die meisten anderen Seiten verwenden die GET-Methode mit RequestParam, also nicht sicher, ob es Konflikte mit dem gibt, was ich hinzufügen möchte, wie in meinem Post erwähnt. – JKJ

+0

Ich bin nicht sicher, was das Problem ist, aber '/ nav/page.do' sollte die richtige URL sein. Vielleicht überprüfen Sie die Protokolle, um zu sehen, warum die interne Fehlerseite angezeigt wird. – tima

Antwort

0

Sie erhalten 500 wegen Kommunikationsverbindungsfehler zwischen Ihrer Datenbank und der Anwendung

org.hibernate.exception.GenericJDBCException: Could not open connection 
    Caused by: org.hibernate.exception.GenericJDBCException: Could not open connection 
    Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure 
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) 
    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 
    Caused by: java.net.ConnectException: Operation timed out (Connection timed out) 
    27-Jul-2017 11:16:46.654 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.loadOnStartup Servlet [MazeFireDispatcher] in web application [] threw load() exception 
    java.net.ConnectException: Operation timed out (Connection timed out) 

Vergewissern Sie sich, dass Ihre Anwendung den Netzzugang zu haben, Ihre Datenbank (und die Firewall blockiert keine Ports für Ihre Datenbank).

Auch here sind einige hilfreiche Informationen darüber.