当前位置: 首页 > 知识库问答 >
问题:

错误:org.apache.jasper.jasperException,如何修复它?

孔欣荣
2023-03-14

我附上以下错误:

在此文件javaclazzweb-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd ">
        <!-- <bean id="xsltViewResolver" class="org.springframework.web.servlet.view.xslt.XsltViewResolver"> 
            <property name="order" value="1"/> <property name="viewClass" value ="org.springframework.web.servlet.view.xslt.XsltView"/> 
            <property name="sourceKey" value="data"/> <property name="suffix" value=".xsl"/> 
            <property name="prefix" value="/xsl/"/> </bean> <bean id="studentDAO" class="edu.java.spring.dao.StudentDAO"> 
            <property name="dataSource" ref="dataSource"/> <property name ="insertSQL" 
            value="insert into student(name,age) values(?,?)"/> </bean> <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> 
            <property name="targetObject"> <ref bean="studentDAO" /> </property> <property 
            name="targetMethod"> <value>createTableIfNotExist</value> </property> <property 
            name="arguments"> <list> <value>student</value> <value>create table student( 
            id bigint primary key generated always as identity(start with 1,increment 
            by 1), name varchar(1000), age integer ) </value> </list> </property> </bean> -->
        <context:component-scan base-package="edu.java.spring.controller" />
        <mvc:annotation-driven />
        <mvc:resources location="/avatar/" mapping="/avatar/**" />

        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="order" value="3" />
            <property name="suffix" value=".jsp" />
            <property name="prefix" value="/student/" />
        </bean>
        <bean id="multipartResolver"
            class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
            <property name="maxUploadSize" value="100000"></property>
        </bean>

        <bean id="xsltViewResolver"
            class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
            <property name="order" value="2" />
            <property name="basename" value="views" />
        </bean>

        <bean id="tilesViewResolver"
            class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="order" value="1" />
            <property name="viewClass"
                value="org.springframework.web.servlet.view.tiles3.TilesView" />
        </bean>

        <bean id="tilesConfigurer"
            class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/tiles/definitions.xml</value>
                </list>
            </property>
        </bean>

        <bean id="studentDao" class="edu.java.spring.dao.impl.StudentHibernateDaoImpl" />
        <bean id="sessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />

            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>

            </property>
            <property name="packagesToScan" value="edu.java.spring.model" />
        </bean>
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="url"
                value="jdbc:derby:D:\PROJECTSPRING\studentdb;create=true" />
            <property name="username" value="" />
            <property name="password" value="" />
        </bean>

        <bean
            class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
            <property name="exceptionMappings">
                <props>
                    <prop key="java.lang.Exception">StudentError</prop>
                </props>
            </property>

        </bean>
        <bean id="studentMapper" class="edu.java.spring.model.StudentMapper" />
    </beans>

此处文件StudentController

@Controller
public class StudentController {
//  @RequestMapping(value = "/student/add", method = RequestMethod.POST)
//  public String addStudent(@Valid Student student,ModelMap model){
//      model.addAttribute("name", student.getName());
//      model.addAttribute("age", student.getAge());
//      return "StudentView";
//  }
    @RequestMapping(value="/student/form",method = RequestMethod.GET )
    public ModelAndView student(){
        return new ModelAndView("StudentForm", "command", new Student());
    }
    @Autowired
    public StudentHibernateDaoImpl studentDAO;

此处文件类StudentHibernateDaoImpl

public class StudentHibernateDaoImpl implements StudentDAO {
    @Autowired
    public LocalSessionFactoryBean sessionFactory;
    @Override
    public void shutdown() {
        // TODO Auto-generated method stub

    }

    @Override
    public void insert(Student student) {
        // TODO Auto-generated method stub

    }

    @Override
    public List<Student> listStudents() {
        // TODO Auto-generated method stub
        Session session = sessionFactory.getObject().openSession();
        Query query = (Query) session.createQuery("from Student");
        try {
            return (List<Student>)query.getResultList();
        } finally {
            // TODO: handle finally clause
            session.close();
        }
    }
public interface StudentDAO {
    public void shutdown();
    public void insert(Student student);
    public List<Student> listStudents();
    public Student loadStudent(int id);
    public void update(Student student);
    public void delete(Integer id);
    public List<Student> searchStudent(String name);


}
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>edu.java.spring</groupId>
  <artifactId>springDAT-MVC</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>springDAT-MVC Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    <version>5.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>4.2.4.RELEASE</version>
</dependency>
    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <version>10.12.1.1</version>
    </dependency>
    <dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
    <version>4.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.13</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>5.5.2</version>
    </dependency>
    <dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-extras</artifactId>
    <version>3.0.5</version>
</dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.3.8.Final</version>
</dependency>


    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.0.5.RELEASE</version>
</dependency>








  </dependencies>
  <build>
    <finalName>springDAT-MVC</finalName>
    <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>true</skipTests>
                    <argLine>-Xmx2524m</argLine>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <fork>true</fork>
                    <compilerArgs>
                        <arg>-XDignore.symbol.file</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.0.M1</version>
                <configuration>
                    <jvmArgs>-Xmx1048m -Xms536m
                        -XX:PermSize=128m -XX:MaxPermSize=512m</jvmArgs>
                    <reload>manual</reload>
                    <systemProperties>
                        <systemProperty>
                            <name>lib</name>
                            <value>${basedir}/target/spring-mvc/WEB-INF/lib</value>
                        </systemProperty>
                    </systemProperties>
                    <scanIntervalSeconds>3</scanIntervalSeconds>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <contextPath>/</contextPath>
                    <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
                    <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                    <classesDirectory>${basedir}/target/classes</classesDirectory>
                </configuration>
            </plugin>

        </plugins>

  </build>
</project>

在此存档学生

package edu.java.spring.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;
@XmlRootElement(name="item")
@Entity
@Table(name = "student",uniqueConstraints={@UniqueConstraint(columnNames="Id")})
public class Student {
//  @NotBlank
//  @Size(min=2,max=100,message ="Age value is invalid")
    private String name;


    private int id;
//  @Range(min=1,max=150)


private int age;
     @XmlAttribute
      @Id

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name ="id", unique=true,nullable =false)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    @XmlElement
    @Column(name = "Name",nullable = false,length = 200)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @XmlElement
    @Column(name = "age",nullable = false)
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }


}

共有1个答案

昝涛
2023-03-14

很明显,这个字符串的问题是

System.out.println6(exp.getMessage()+"<br/>");

您应该使用system.out.println,而不是system.out.println6

System.out.println(exp.getMessage()+"<br/>");
 类似资料:
  • ProjectAAA.obj:错误LNK2001:未解析的外部符号" public:_ this call X::class event::class event(unsigned int)"(??0类事件@X@@QAE@I@Z) 我已经定义了不知道如何修复这个LINK错误。 欢迎提出任何建议。 谢谢你 更多信息: 1. 现在我已经完全隔离了错误: 1.

  • 错误是这样的 描述资源路径位置类型 在解决构建路径错误之前无法构建项目abc未知Java问题未绑定类路径容器:'JRE System Library[OSGi/最小值-1.2]'in project'abc'abc构建路径构建路径问题 我想当我去那里的时候,它就发生在安装的Jre那里,我没有看到Jre Im还使用Mac os x 10.10.1 yosemite 我怎样才能解决这个问题?

  • 问题内容: 向MySQL发出命令时,出现错误#1064“语法错误”。 这是什么意思? 我该如何解决? 问题答案: 错误#1064表示MySQL无法理解您的命令。要解决这个问题: 阅读错误消息。 它 准确地 告诉您MySQL 在命令中哪里 混淆了。 检查您的命令。 如果您使用的编程语言来创建你的命令,使用,或同等学历,以显示 完整的命令 ,所以你可以看到它。 检查手册。 通过对MySQL的什么比较

  • 尝试了许多解决办法,但都无济于事 参考:在当前主题中找不到样式“协调器LayoutStyle” 但没有帮助 底部App Bar材质设计 应用程序条:底部材质设计

  • 我正在编程一个需要Hibernate技术的项目。我得到了堆栈痕迹,但我不知道如何修复它。有什么需要帮忙的吗? 这是我的堆栈跟踪,我得到了这两个错误: SLF4J:slf4j-api 1.6.x(或更高版本)与此绑定不兼容。SLF4J:您的绑定是1.5.5或更早版本。SLF4J:将绑定升级到1.6.x版本。或2.0.x 导入org.hibernate.hibernateException;导入org