Search code examples
javaspringmodelattribute

ModelAttribute in .jsp file: Can not resolve symbol. Spring


I have primitive spring project for learning Spring framework. In my .jsp file I'm getting exception below: enter image description here

But in my controller class I have @ModelAttribute("student"):

enter image description here

Bellow is my project structure:

enter image description here

In my web.xml file I have exception too:

enter image description here

Here is my Artifacts: enter image description here

Will be glad to any help. Thanks.


Solution

  • If you have same problem like me, you have to configure dispatcher servlet and mapping like in my web.xml. Resolving symbol error in web.xml means that in your pom.xml you shoul write: <packaging>war</packaging>. It works for me.

    My pom.xml:

     <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.spring</groupId>
        <artifactId>SpringgMVC</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
    
         <dependencies></dependencies>