菜鸟求解答……
想用SSH写个列车查询,技术很菜……求指点0-0
刚开始就卡壳了……
写“车次查询”这个功能,就是输入个车次,出现该车次的始发、终点、车型,可是老是出现500错误,新手求教;
JSP:
<%@ page language="java" import="java.util.*,com.train.Model.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
TrainMain trainmain = new TrainMain();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'QTrainId.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<s:form action="actions/QBid.action?trainmain.tid=%{#trainmain.tid}" method="post">
<s:textfield name="trainmain.tid" label="车次"></s:textfield>
<s:submit value="查询"></s:submit>
</s:form>
</body>
</html>
Action:
package com.train.action;
import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.train.Model.TrainMain;
import com.train.Model.TrainMainDAO;
public class QBidAction extends ActionSupport
{
/**
* @return the trainmain
*/
public TrainMain getTrainmain()
{
return trainmain;
}
/**
* @param trainmain the trainmain to set
*/
public void setTrainmain(TrainMain trainmain)
{
this.trainmain = trainmain;
}
/**
* @return the message
*/
public String getMessage()
{
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message)
{
this.message = message;
}
private TrainMain trainmain;
private String message;
/**
* @return
*/
public String execute() throws Exception
{
BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
TrainMainDAO dao = (TrainMainDAO)factory.getBean("TrainMainDAO");
Map request = (Map)ActionContext.getContext().get("request");
trainmain = (TrainMain) dao.findByTid(trainmain.getTid());
request.put("list", dao.findById(trainmain.getId()));
// TODO Auto-generated method stub
return SUCCESS;
}
}
list1页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'list1.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table border="1" width="80%" align="center">
<tr>
<td>车次</td>
<td>始发</td>
<td>终点</td>
<td>车型</td>
</tr>
<s:iterator value="#request.list" id="train">
<tr>
<td>
<s:property value="#train.tid"/>
</td>
<td>
<s:property value="#train.start"/>
</td>
<td>
<s:property value="#train.over"/>
</td>
<td>
<s:property value="#train.kind"/>
</td>
</tr>
</s:iterator>
</table>
</body>
</html>
最后显示的是500错误……
The server encountered an internal error () that prevented it from fulfilling this request.
[解决办法]
错误贴出来啊
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html