struct2 配置问题详解

 最近刚刚学习struct2,按照Struts 2权威指南--基于WebWork核心的MVC开发 上面的配置进行第一个struct例程学习。

 纯手写的 呵呵。。。

 

 1、web.xml

  <?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">
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

2、struts.xml

<?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>  
 <package name="lee" extends="struts-default" >
  <action name="Login" class="LoginAction">
   <result name="error">error.jsp</result>
   <result name="success">welcome.jsp</result>
  </action>
 </package>

</struts>

3、struts.properties

struts.devMode = true
struts.enable.DynamicMethodInvocation = false

4、lib 中包(struts2-blank-2.1.6 例程下面的 lib <此例程是struct2 自带 位于 apps目录下面>)

 

上面就是我刚刚开始配置文件,放到 tomcat 的 webapp文件夹下面

现在就说说容易出现问题

1、配置文件的拼写 我就是把struts.xml 写错了

2、在xml中尽量不要写空格,在goolge中看到一位老兄就是因为这个问题出现错误

3、lib下面尽量的包括struts2-blank-2.1.6下面的lib不要包括其他的,我就是因为包括了一个struts2-spring-plugin-2.1.6.jar 导致出错

4、不知道为什么我写的struts.properties总是不对,于是把他的内容放到struts.xml 中

     在其中增加两句话
   <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />

5、如果按照我上面配置的问题 基本可以运行了。

6、在jsp中action 中的名字就是 在struts 中配置的名字,在网上看到有还多原因是在jsp中action名字后面没有加.action.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值