使用ServletUnit测试JSP的示例 [英] example of using ServletUnit to test JSP's

查看:84
本文介绍了使用ServletUnit测试JSP的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我指出一个如何使用ServletUnit来测试JSP的示例吗?我需要调用registerServlet()吗?如果是这样,我要通过什么班级名称?

Can anyone point me to an example of how to use ServletUnit to test JSP's? Do I need I need to call registerServlet()? If so, what class name do I pass?

推荐答案

如果要使用默认的Jasper编译器,则无需注册Servlet.但是,我需要Jasper jar和它们对CLASSPATH的依赖.我需要一个基本的JSP进行编译和渲染的Maven依赖项是:

You do not need to registerServlet if you are going use the default Jasper compiler. However, I needed Jasper jars and their dependencies on the CLASSPATH. The Maven dependencies I needed to get a basic JSP to compile and render were:

<dependency>
  <groupId>tomcat</groupId>
  <artifactId>jasper</artifactId>
  <version>3.3.2</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>tomcat</groupId>
  <artifactId>jasper-compiler</artifactId>
  <version>5.5.23</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>tomcat</groupId>
  <artifactId>tomcat-util</artifactId>
  <version>5.5.23</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>tomcat</groupId>
  <artifactId>core_util</artifactId>
  <version>3.3.2</version>
  <scope>test</scope>
</dependency>

我被困在JDK1.4项目中,因此您可以使用较新的版本.我还没有标准的taglib工作呢...

I am stuck in a JDK1.4 project,so you may be able to use newer versions. I haven't gotten standard taglib working yet...

这篇关于使用ServletUnit测试JSP的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆