gpt4 book ai didi

java - struts 1.3 hibernate jsp mysql

转载 作者:行者123 更新时间:2023-11-29 21:16:36 24 4
gpt4 key购买 nike

我想使用 hibernate 和 mysql 将数据映射到 jsp 页面。一切工作正常,但当我单击链接时,它显示 404。下面是附加的代码。任何人都可以提供解决方案..提前感谢。

这是我的initExecute代码,

public ActionForward initExecute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
{
TestForm test = new TestForm();
try {
test.reset();
setRequiredData(test);
} catch (Exception e) {
e.printStackTrace();
}
return mapping.findForward("success");
}

这是我的struts-config代码,

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
<message-resources parameter="resources.Application" />
<form-beans>
<form-bean name="test" type="com.project.forms.TestForm"/>
</form-beans>

<global-forwards>
<forward name="success" path="/jsp/subject.jsp"/>
</global-forwards>

<action-mappings>

<action path="/Select" type="com.project.actions.TestAction" name="test" parameter="method">
<forward name="success" path="/jsp/subject.jsp" />
</action>
</action-mappings>
</struts-config>

这是我的index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GlassFish JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<hr/>
<a href="Select.do?method=initExecute">Welcome</a>
</body>
</html>

这是堆栈跟踪:

java.sql.SQLException: Access denied for user 'sashi'@'localhost' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2748) at com.mysql.jdbc.Connection.(Connection.java:1553) at com.project.actions.TestAction.setRequiredData(TestAction.java:78) at com.project.actions.TestAction.initExecute(TestAction.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

SEVERE: PWC6117: File "E:\All Checkouts.metadata.plugins\org.eclipse.wst.server.core\tmp0\SimpleProject\jsp\subject.jsp" not found

最佳答案

我在这里看到两个可能的问题:

1.jsp 页面未找到 - 尝试将路径设置为 path="/WEB-INF/jsp/subject.jsp"

2.jdbc连接不正确-检查hibernate配置

关于java - struts 1.3 hibernate jsp mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com