ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1026
1026
EMPFEHLEN
-
Hallo!
ich versuche eine Beispielanwendung zu bauen, die mit Hibernate und Spring MVC (3.0.0) arbeitet... Verwenden möchte ich dabei Annotations.
Der Hibernate-Part ist abgeschlossen und funktioniert, allerdings die Controller nicht.
Ich bekomme keine Exceptions, sondern einen stinknormalen 404 beim Aufruf von z. B. http://[domain]/Blog/ oder http://[domain]/Blog/post/.
Controller:
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
@Controller @RequestMapping("/post/**") public class PostController { @Autowired private IPostService postService; @RequestMapping(value = "/", method = RequestMethod.GET) public String list(ModelMap modelMap) { modelMap.addAttribute("posts", this.postService.getAllPosts()); return "post/"; } @RequestMapping(value = "/{id}", method = RequestMethod.GET) public String show(@PathVariable("id") Long id, ModelMap modelMap) { Assert.notNull(id, "Id must be provided."); modelMap.addAttribute("post", this.postService.getPostById(id)); return "post/"; } // usw. // weitere Methoden sind entfernt, um Übersichtlichkeit zu erhalten...
Config blog-servlet.xml:
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?xml version="1.0" encoding="UTF-8"?> <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 [url]http://www.springframework.org/schema/beans/spring-beans-2.0.xsd[/url] [url]http://www.springframework.org/schema/context[/url] http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="controller" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name ="prefix" value="/WEB-INF/jsp/" /> <property name ="suffix" value=".jsp" /> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> </beans>
sowie web.xml
Code xml:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Blog</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>blog</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>blog</servlet-name> <url-pattern>/Blog/*</url-pattern> </servlet-mapping> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>1000</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> </web-app>
Seht Ihr da einen grundlegenden Fehler in der Klasse oder Konfiguration?
Erreichen möchte ich URLs von dieser Form:
Gruß
FelixGeändert von Wyatt (24.02.10 um 16:54 Uhr)
Ähnliche Themen
-
Spring mit Annotations
Von Looky im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 1Letzter Beitrag: 07.10.10, 13:19 -
Hibernate-Annotations-Problem
Von 7bkahnt im Forum JavaAntworten: 2Letzter Beitrag: 23.04.10, 13:43 -
[Hibernate] Problem mit Annotations
Von AndreBrueck im Forum Relationale DatenbanksystemeAntworten: 0Letzter Beitrag: 28.06.09, 22:01 -
Spring Dependency Injection - XML oder Annotations?
Von DarthShader im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 5Letzter Beitrag: 22.09.08, 19:07 -
Spring 2.5.5 JBoss 4.2.2 Hibernate-Annotations (Dringend !)
Von Smokey67 im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 5Letzter Beitrag: 21.09.08, 18:47





Zitieren
Login





