<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>FirstSpringMVC</display-name>
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<!-- Map all requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="org.springframework.samples.petclinic.web"/>
<!-- Helper controller class -->
<bean id="HandlerMapping"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"
></bean>
<!-- Req. process Controller class -->
<bean name="/Welcome.html" class="C:/Users/Vijay Mekala/Desktop/SAP/Java Spring/FirstSpringMVC/src/com/vijay/hellocontroller/HelloController"></bean>
<!-- View Resolver class -->
<bean id="ViewResolver"
class="org.springframework.web.servlet.view.InternalResourceviewResolver"
>
<property name="prefix">
<value>/WEB-INF</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
package com.vijay.hellocontroller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
public class HelloController extends AbstractController{
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView modelandview = new ModelAndView("Hellopage");
modelandview.addObject("welcomemessage", "Welcome to MVC 1st Application");
return modelandview;
// return null;
}
}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>First MVC App OM</title>
</head>
<body>
<h2>
${welcomemessage}
</h2>
</body>
</html>
更多的细节:
我正在尝试创建第一个没有注释的Spring MVC应用程序。下面是我的URL请求'http://localhost:8080/firstspringmvc/welcome.html',它调用了我的代码。
以下是我的错误列表供参考:
在您的代码中有几处需要更正。
1)组件扫描基本封装应更改-
<context:component-scan base-package="com.vijay.hellocontroller"/>
2)应更正Bean创建
<bean id="someid" class="com.vijay.hellocontroller.HelloController"></bean>
@Controller
public class HelloController extends AbstractController
http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/
目前正在努力部署WAR8.5中的war文件,但每次我启动我的war文件时,都会出现一个错误。 初始化上下文时捕获异常:{0}org.springframework.beans.factory.beanCreationException:创建ServletContext资源[/web-inf/my-servlet.xml]中定义的名为“Entity ManagerFactory”的bean时出错:调
问题内容: 问题: 我正在为在类中执行方法创建切入点。该类是控制器类,由注解@Controller表示,因此对于方面所要求的相同,不需要bean。我附加了dispathcher servlet代码,方面和控制器类。有人可以识别出问题所在。 DISPATCHER SERVLET : 方面: 控制器类别: 控制台错误: 问题答案: 这是Spring AOP中的限制。当你使用AspectJ切入点将方面编
我使用hibernate 3.2.7和spring 3.2.8。错误是*** **“:创建ServletContext资源[/WEB-INF/Spring-Servlet.xml]中定义的名称为'session Factory'的bean时出错:init方法调用失败;嵌套异常为java.io.FileNotFoundException:ServletContext资源[/resources/hib
我创建了一个Spring App,我使用hibernate进行逆向工程,从MySQL Db生成java类。之后,我想使用这个类来实现存储库,但我有这个问题: 组织。springframework。豆。工厂BeanCreationException:创建名为“entityManagerFactory”的bean时出错,该bean在类路径资源[org/springframework/boot/auto
我面临一些问题,而连接Redis(“使用Redisson”)与spring Boot。在应用开始时间显示以下错误。 “org.springframework.beans.factory.beanCreationException:创建类路径资源[com/redisson/config/redisconfig.class]中定义的名为'redisson'的bean时出错:通过工厂方法实例化bean失