解决方案 »
- 如何使用log4j使得两个类生成各自的log
- 关于正则表达式的问题
- 重新开一帖,关于文件读取
- 如何用JNDI修改AD账户的password
- 移动网关SP端短信群发
- 怎么才能比较时间 取得的本地时间与nyr进行比较
- 很难噢!!用java实现统计净代码行数,给点思路!!!
- 提示这种错误“Exception in thread "main" java.lang.NoClassDefFoundError: first"
- 想问问sendUrgentData这个方法是怎么用的
- 新手请教!!!!
- jmf资料
- String 转化为 Integer java.lang.NumberFormatException: For input string: "22"
你中间少了一个/
访问路径应该是http://localhost:8080/Demo/hello/demo/doDemoQuery.action
你中间少了一个/
-------------------------------
正确路劲就是我上面说的..demo*是表示我访问action的时候前面需要加demo
在struts.xml的struts标签中加上一行<include file="struts-default.xml"/>
---------------------------------------------------------------------
加上也没用的!
<action name="demo*" class="demoAction" method="{1}">改成<action name="demo*" class="com.demo.action.DemoAction" method="{1}">呢?
--------------------------------------------------------------------------------
这样改了也没用的.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd"> <!-- 启用spring注解支持 -->
<context:annotation-config /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver">
</property>
<property name="url" value="jdbc:oracle:thin:@192.168.1.183:1521/WSLDEV">
</property>
<property name="username" value="wsladmin"></property>
<property name="password" value="password"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
</bean> <!--
定义事务处理类,不同的数据访问方式,事务处理类不同
比如:Hibernate操作的HibernateTransactionManager,JDBC操作的使用DataSourceTransactionManager
-->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean> <!-- 定义事务通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义方法的过滤规则 -->
<tx:attributes>
<!-- 所有方法都使用事务 -->
<tx:method name="*" propagation="REQUIRED" />
<!-- 定义所有get开头的方法都是只读的 -->
<tx:method name="get*" read-only="true" />
</tx:attributes>
</tx:advice> <!-- 定义AOP配置 -->
<aop:config>
<!-- 定义一个切入点 -->
<aop:pointcut expression="execution (* com.demo.dao.*.*(..))"
id="services" />
<!-- 对切入点和事务的通知,进行适配 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="services" />
</aop:config></beans>
form里的action=? 是/hello/demodoDemoQuery.action吗?
--------------------------------------------------------------------
对的.
你的<package name="demo" extends="struts-default" namespace="/hello">
<action name="demo*" class="demoAction" method="{1}">
<result name="doDemoQuery">/jsp/demoList.jsp</result>
</action>
</package>
访问的时候acion=/hello/demodoDemoQuery.action
还有你的类名,应该为com.demo.action.DemoAction吧
<!-- 将对象交给spring管理 -->
<constant name="struts.objectFactory" value="spring" />这个有吗?
<init-param>
<param-name>struts.convention.action.packages</param-name>
<param-value>cn.damai.mplus.activity.channel.action</param-value>
</init-param>
<bean id="uploadAction" class="com.ec.action.UploadAction">
<property name="uploadService" ref="uploadService"></property>
</bean>
希望我的回答能给你带来帮助
你的web.xml里面的映射
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping> 既然楼主把<url-pattern>*.action</url-pattern>设置为了*.action那么你的URL必定是以 .action 结尾 这一点我想不会有疑问
但是你的路径
3.访问路劲:http://localhost:8080/Demo/hello/demodoDemoQuery.action
为什么最后是/demodoDemoQuery.action呢?
我看了楼主的action方法中并没有名为 demodoDemoQuery 的方法!
如果没有 demodoDemoQuery 这个方法那么服务器怎么找得到呢?
在这里我提出我的解决方法:
1.最直接的 URL改为 http://localhost:8080/Demo/hello/doDemoQuery.action
2.更改<url-pattern>标签值为 <url-pattern> demo*.action</url-pattern>
3.你还可以修改struts.xml中的package标签中的namespace属性为
namespace="/hello/demo"
同时修改你的 访问路径为
http://localhost:8080/Demo/hello/demo/doDemoQuery.action希望这点内容能对楼主和每个关心这个问题的人给以帮助,希望楼主早日解决问题并结贴。
第二个解决方案是错误的
其中第二个解决方案如果你需要可以设值
struts.action.extension 常量的值
<constant name="struts.action.extension" value =
但是想在 action 方法名前面加其他东西是行不通的抱歉,如果有其他错误还望大家指正