我希望我的 servlet 页面检索 jsp 页面的 textarea 中提供的信息,并将该文本转换为语音并返回到 jsp 页面。这段代码给了我这个错误
org.apache.catalina.core.StandardWrapperValve invokeSEVERE: Servlet.service() for servlet [Myclass] in context with path [/test] throw exception [Servlet execution throw an exception] with root cause java.lang.ClassNotFoundException: com.sun .speech.freetts.VoiceManager在 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
任何帮助或建议将不胜感激。
servlet 页面 (Myclass.java)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//2nd approach
final String VOICENAME ="kevin16" ;
String button = request.getParameter("button");
Voice voice;
VoiceManager vm= VoiceManager.getInstance();
voice =vm.getVoice(VOICENAME);
voice.allocate();
if ("text".equals(button)) {
try {
voice.speak(request.getParameter("box"));
}
catch( Exception e){
System.out.println(e.getMessage());
}
System.out.println("line 5");
request.getRequestDispatcher("NewFile.jsp").forward(request, response);
}
}
}
jsp 页面 (NewFile.jsp)
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="post" action="Myclass" enctype="multipart/form-data">
<textarea name ="box" rows="4" cols="50">
</textarea>
<button value="text" name ="button" type="submit" >Click Me!</button>
</form>
</body>
</html>