xuhanchn
2016-07-30 03:44
采纳率: 92.7%
浏览 1.3k
已采纳

action="/user" 不跳转到根目录

框架是struts1.3
jsp在form文件夹下
本来应该跳转到根目录的
但是url每次都跳转到/form/user?...

.
.

下面是相关代码
.
.
.
signin.jsp,放在webroot/form文件夹下。
(form那块第一部分注释掉的是原本用struts的html标签做的,这个是可以正常跳转的。但我想用普通的html标签,但就是不行。。)

 <%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<html> 
    <head>
        <title>JSP for UserForm form</title>
    </head>
    <body>
        <%-- <html:form action="/user">

            <html:hidden property="action" value="signin"/>
            账号 : <html:text property="account"/><html:errors property="account"/><br/>
            密码 : <html:password property="pwd"/><html:errors property="pwd"/><br/>
            <html:submit/><html:cancel/>
        </html:form> --%>

        <form action="/user">
        账户 : <input type="text" name="account" value="admin1"><br>
        密码 : <input type="text" name="pwd" value="1q!"><br>
        <input type="submit" value="Submit">
        </form>

    </body>
</html>

struts-config

<?xml version="1.0" encoding="UTF-8"?>
<!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>
  <form-beans >
    <form-bean name="userForm" type="com.changhe.struts.form.UserForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      attribute="userForm"
      input="/form/signin.jsp"
      name="userForm"
      path="/user"
      scope="request"
      type="com.changhe.struts.action.UserAction"
      cancellable="true">
      <forward name="failure" path="/result/failure.jsp" />
      <forward name="success" path="/result/success.jsp" />
    </action>

  </action-mappings>

  <message-resources parameter="com.changhe.struts.ApplicationResources" />
</struts-config>

web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>ncdba2_0</display-name>
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</web-app>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 鱼弦 2016-07-30 04:07
    已采纳
    点赞 评论
  • 改成:

    点赞 评论
  • 雾非雾,花非花 2016-07-30 05:27

    很显然路径错了啊,看看配置什么的

    点赞 评论

相关推荐 更多相似问题