• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

46_Spring WEB

21.10.10 07:52 작성 조회수 345

0

Servlet의 버전을 3.1.0으로 올리니 아래와 같이 에러가 발생합니다.

답변 4

·

답변을 작성해보세요.

1

올려주신 내용중 web.xml에 2군데가 중복인데 하나를 지워주셔야 됩니다.
2군데 라면 아래내용 빨강색을 지워주시고 다시 제가 설명한데로 해보시기 바랍니다.

<?xml version="1.0" encoding="UTF-8"?>

 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xmlns="http://xmlns.jcp.org/xml/ns/javaee"

 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

 id="WebApp_ID" version="3.1"> 

///////////////////////////////////////////////////////////////////////////////
제가 다시 강의에 올려져 있는 파일로 확인을 했는데 에러는 나지 않는데요.

다시한번 설명해보겠습니다.

1. pom.xml에  servlet 3.1.0 으로 API 변경 확인해주시구요.

<!-- servlet 3.1.0 으로 API 변경 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

2.  FileController.java 파일에서 
1) import 부분에서 에러나는 부분을 삭제하시고
2)다시 HttpServletRequest에서 마우스를 올리시고 import를 해보시기기 바랍니다.

3. 이렇게 해도 에러가 없어지지 않으시면 첨부파일에 있는 파일을 import해서 진행해보시기 바랍니다.

0

혹시 web.xml 은 어떻게 수정하셨는지요? 한번 올려줘보세요.

jh님의 프로필

jh

질문자

2021.10.10

<?xml version="1.0" encoding="UTF-8"?>

 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xmlns="http://xmlns.jcp.org/xml/ns/javaee"

 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

 id="WebApp_ID" version="3.1"> 

<!-- Character Encoding -->

<filter>

<filter-name>encodingFilter</filter-name>

<filter-class>org.springframework.web.filter.CharacterEncodingFilter

</filter-class>

 

<init-param>

<param-name>encoding</param-name>

<param-value>utf-8</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>encodingFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

<!-- The definition of the Root Spring Container shared by all Servlets 

and Filters -->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring/root-context.xml</param-value>

</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener

</listener-class>

</listener>

<!-- Processes application requests -->

<servlet>

<servlet-name>appServlet</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet

</servlet-class>

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring/appServlet/servlet-context.xml

</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>appServlet</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

</web-app>

 

0

jh님의 프로필

jh

질문자

2021.10.10

메이븐 업데이트 해도 아래와 같은 에러 메세지가 계속나오는데요 ㅠ.ㅠ

The method getServletContext() is undefined for the type HttpRequest

0

서블릿 버전을 변경하셨으면, web.xml도 수정하시고 프로젝트 clean, 메이븐 업데이트 해보시기 바랍니다.^^ 강의 영상에 변경방법이 설명되어 있을것입니다.