你自己可以先把你写的有struts标签的jsp页面翻译成没有不带标签的就行。
看看struts的一些文档,比如MasteringJakartaStruts.pdf
<html:password property="password" /> 翻译成
<input type="password" name="password" value="">
看看struts的一些文档,比如MasteringJakartaStruts.pdf
<html:password property="password" /> 翻译成
<input type="password" name="password" value="">
解决方案 »
- web负载,请有经验的人指导一下,谢谢
- struts 跳转
- 在北京Java程序员工资多少?
- 请问我的hibernate代码怎么总是提示org.hibernate.MappingException: Resource: Person.hbm.xml not found
- 小女子不才,接触J2EE/EJB不久碰到的问题!跪求帮助!!!
- eclipse+myeclipse+tomcat开发程序??
- fdsfads
- 怎样读取数据库中的值到下拉列表框中?请帮我看下代码
- 架设自己的Wiki
- 象删除记录这样的操作并没有actionForm,那么在struts里怎么完美的解决这种操作呢?
- 高分求救:struts与工作流可以结合吗?业务逻辑中的流程控制可以采用工作流开发吗?
- 月薪6000~15000 招聘懂日语,英语Java 工程师
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html locale="true">
<head>
<title>RegUser</title>
</head>
<body bgcolor="white">
<form action="/regUserAction" focus="logname">
<table border="0" width="100%">
<tr>
<th align="right">
Logname:
</th>
<td align="left">
<INPUT TYPE="text" NAME="logname" size="20" maxlength="20">
</td>
</tr>
<tr>
<th align="right">
Password:
</th>
<td align="left">
<INPUT TYPE="password" name="password" size="20" maxlength="20">
</td>
</tr>
<tr>
<th align="right">
E-mail:
</th>
<td align="left">
<INPUT TYPE="text" NAME="email" size="30" maxlength="50">
</td>
</tr>
<tr>
<td align="right">
<INPUT TYPE="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>struts-config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><!--
This is the Struts configuration file for the example application,
using the proposed new syntax.
-->
<struts-config>
<action-mappings>
<action path="/regUserAction"
type="RegUserAction"
scope="request"
validate="false">
<forward name="failure" path="/messageFailure.jsp"/>
<forward name="success" path="/messageSuccess.jsp"/>
</action>
</action-mappings>
</struts-config>RegUserAction.java:
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;public final class RegUserAction extends Action
{ public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
String title = req.getParameter("title");
String password = req.getParameter("password");
String email = req.getParameter("email");
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(ClassNotFoundException e){
System.out.println("SQLServerDriver not found!");
return (mapping.findForward("failure"));
}
try{
String url="jdbc:microsoft:sqlserver://192.168.0.254:1433;DatabaseName=zw_test;User=sa;Password=sa";
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String SQL;
/*
取得用户请求,做相应数据库操作,略
*/
}catch(SQLException e){
System.out.println("Error to connect the database!");
return (mapping.findForward("failure"));
}
return (mapping.findForward("success"));
}
}
然后运行http://127.0.0.1:8080/demo/register.jsp提交。。错误如下:
HTTP Status 404 - /regUserAction
--------------------------------------------------------------------------------
type Status report
message /regUserAction
description The requested resource (/regUserAction) is not available.
Apache Tomcat/4.1.29
description The requested resource (/regUserAction) is not available.
你的Struts没有起作用
既然
上头要我赶紧交出一个基于struts的demo页面
那么你不妨把struts自带的几个例子改改拿给他看好了。
谢谢你啦~~~
重新试一下,应该可以的。
tomcat是4.1.9的
jdk是1.4.2
:(都不错的 阿