在windows下面部署web项目 struts2能成功跳转页面,但是在linux下面就失败,出现404错误!
在windows下面部署web项目 struts2能成功跳转页面,但是在linux下面就失败,出现404错误!
代码:
index.jsp
- HTML code
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%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 'index.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> <a href="gotest">测试</a> </body></html>
web.xml:
- XML code
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
struts.xml:
- XML code
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="false" /> <package name="default" namespace="/" extends="struts-default"> <action name="go*" class="com.cn.web.TestAction" method="{1}"> <result>show.jsp</result> </action> </package> <!-- Add packages here --></struts>TestAction.java 代码:
- Java code
package com.cn.web;import com.opensymphony.xwork2.ActionSupport;public class TestAction extends ActionSupport { public String test(){ System.out.println("我进来了"); return SUCCESS; }}在windows下面能正常跳转,但是部署在linux 下面就出现了404错误!
linux 环境:tomcat+nginx
各位高手帮帮忙!
------解决方案--------------------
两种操作系统的处理方式不一样,出现问题时应该先看下两种操作系统本质的区别,然后再处理
[解决办法]
有些代码在这两种系统是不兼容的
[解决办法]
系统的兼容性问题
[解决办法]
看看是不是项目的路径设置有问题。检查一下文件是否存在。我感觉是是你项目路径的设置问题。
[解决办法]
楼主先查下是不是项目部署路径问题,WINDOWS和LINUX路径写法不同。
[解决办法]
404错误 是不是没找到那个文件呀,这2种系统的路径写法不同